FZU2216
来源:互联网 发布:windows串口编程实例 编辑:程序博客网 时间:2024/04/26 12:26
#include <iostream>#include <string>#include <string.h>#include <vector>#include <stdio.h>#include <algorithm>#include <map>#include <math.h>typedef long long LL ;std::vector<int> stone ;int main(){ int t , limit , x , n , m , L , R , used , unUsed ; scanf("%d" , &t) ; while(t--){ limit = 0 ; stone.clear() ; scanf("%d%d" , &n , &m) ; for(int i = 0 ; i < n ; i++){ scanf("%d" , &x) ; if(x) stone.push_back(x) ; else limit++ ; } std::sort(stone.begin() , stone.end()) ; stone.erase( std::unique(stone.begin() , stone.end()) , stone.end() ) ; int res = std::min(m , limit) ; for(L = 0 , R = 0 ; L < stone.size() ; L++){ while(R < stone.size() && stone[R] - stone[L] + 1 <= R - L + 1 + limit) R++ ; R-- ; used = (stone[R] - stone[L] + 1 ) - ( R - L + 1 ) ; unUsed = limit - used ; res = std::max(res , stone[R] - stone[L] + 1 + std::min(unUsed , m - (stone[R] - stone[L] + 1))) ; } std::cout<< res << std::endl ; } return 0 ;}
0 0
- FZU2216
- FZU2216【二分】
- FZU2216 The Longest Straight
- FZU2216 最长连续子序列
- The Longest Straight(FZU2216)
- fzu2216 0可以代替任何数字,问打出的顺子最大长度?
- Pixhawk之姿态解算篇(4)_补充篇
- 部分和问题
- 大数据时代,为什么使用Spark框架?
- 基于MT7688模块的开发笔记1——关于Ubuntu版本
- flex布局
- FZU2216
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 去掉Scrollview滑动顶部和顶部阴影
- 使用Dockerfile创建支持sshd服务自启动的容器镜像(Ubuntu14.04)
- 有关于缓存的 判断
- Paint及Canvas的简单应用
- ios 打印 结构体
- ajax传输字符串
- ZZULIOJ 1879: 蛤玮买好了礼物【数学】