fzu 2216 The Longest Straight
来源:互联网 发布:scratch创意编程 pdf 编辑:程序博客网 时间:2024/06/05 13:28
Description
ZB is playing a card game where the goal is tom make straights. Each card in the deck has a number between 1 and M, inclusive. A straight is a sequence of cards with consecutive values. Values do not wrap around, so 1 does not come after M. In addition to regular cards, the deck also contains jokers. Each joker can be used as any valid number (between 1 and M, inclusive).
You will be giben N integers card[1]...card[n] referring to the cards in your hand. Jokers are represented by zeros, and other cards are represented by their values. ZB wants to know the number of cards in the longest straight that can be formed using one or more cards from his hand.
Input
The first line contains an integer T, meaning the number of the cases.
For each test case:
The first line there are two integers N and M in the first line (1 <= N, M <= 10^5), and the second line contains N integers card[i](0 <= card[i] <= M).
Output
For each test case, output a single integer a line -- the longest straight ZB can get.
Sample Input
27 110 6 5 3 0 10 118 1000100 100 100 101 100 99 97 103
Sample Output
53
时间复制度为O(N)
- fzu 2216 The Longest Straight
- fzu 2216 The Longest Straight
- The Longest Straight FZU
- FZU 2216 The Longest Straight (二分)
- FZU 2216 The Longest Straight 枚举+二分
- FZU 2216 The Longest Straight (二分)
- fzu 2216 The Longest Straight 二分
- FZU 2216 The Longest Straight (二分+01优化)
- Fzuoj 2216 The Longest Straight 【二分 || 模拟】
- FOJ Problem 2216 The Longest Straight
- The Longest Straight
- FZU2216 The Longest Straight
- FZU Problem 2216 The Longest Straight(二分答案+树状数组)——第六届福建省大学生程序设计竞赛-重现赛
- The Longest Straight(FZU2216)
- FZU_2216 The Longest Straight (二分)
- FZUoj 题目2216 The Longest Straight*(二分)
- FZOJ 2216 The Longest Straight (尺取法)
- 2015福建省赛 fzoj The Longest Straight
- PE文件格式详解(4)
- 基于Swift的iOS应用程序开发:字符串String与Data数据类型相互转换
- 【mybatis】--mapper代理实现dao
- RAID阵列实验
- JavaScript基础(改变html元素内容)
- fzu 2216 The Longest Straight
- 捕捉桌面上的窗口信息
- LintCode:转换字符串到整数
- git入门大全
- 小时到分钟
- 路径寻找问题
- 复习1
- Linux 安装 oh my zsh
- redis哨兵、集群