补提交卡
来源:互联网 发布:网络新媒体概论微盘 编辑:程序博客网 时间:2024/06/08 03:34
小Ho给自己定了一个宏伟的目标:连续100天每天坚持在hihoCoder上提交一个程序。100天过去了,小Ho查看自己的提交记录发现有N天因为贪玩忘记提交了。于是小Ho软磨硬泡、强忍着小Hi鄙视的眼神从小Hi那里要来M张"补提交卡"。每张"补提交卡"都可以补回一天的提交,将原本没有提交程序的一天变成有提交程序的一天。小Ho想知道通过利用这M张补提交卡,可以使自己的"最长连续提交天数"最多变成多少天。
第一行是一个整数T(1 <= T <= 10),代表测试数据的组数。
每个测试数据第一行是2个整数N和M(0 <= N, M <= 100)。第二行包含N个整数a1, a2, ... aN(1 <= a1 < a2 < ... < aN <= 100),表示第a1, a2, ... aN天小Ho没有提交程序。
对于每组数据,输出通过使用补提交卡小Ho的最长连续提交天数最多变成多少。
3 5 1 34 77 82 83 84 5 2 10 30 55 56 90 5 10 10 30 55 56 90
76 59100
啥也不说了,直接代码吧:
#include <stdio.h>#include <iostream>#include <algorithm>#include <stdlib.h>#include <string.h>#include <stdlib.h>using namespace std;int absent[105];int ans(int n, int m){ if(m>=n) return 100; int cnt, maxx=0; int i=0; while(i+m+1<=n+1){ cnt=absent[i+m+1]-absent[i]-1; //补卡一定是补连续的才能得到最长序列; maxx=max(maxx, cnt); i++; } return maxx;}int main(){ int T; scanf("%d",&T); while(T--){ int N, M; cin >> N >> M; absent[0]=0; for(int i=1; i<=N; i++) cin >> absent[i]; absent[N+1]=101; cout << ans(N, M) << endl; } return 0;}
阅读全文
0 0
- hihcoder:补提交卡
- 1051 补提交卡
- hihoCoder1051 - 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- 补提交卡
- 补提交卡
- hihocoder-补提交卡
- #1051 : 补提交卡
- 1051 : 补提交卡
- #1051 补提交卡
- hiho1051 : 补提交卡
- [hihocoder1015]补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- hihocoder :补提交卡
- 补提交卡 HihoCoder
- Lua 基本语法
- Scrapy爬虫入门教程 安装和基本使用
- php使用Url读取文件的内容及file_get_contents用法
- php ip2long 出现负数原因及解决方法
- BZOJ1023: [SHOI2008]cactus仙人掌图(单调队列优化DP)
- 补提交卡
- 安装Scala-2.11.7——集群学习日记
- 关于DataGridView 控件的使用
- Linux中if语句中-的意义
- 山寨币交易平台开发完成后源码如何链接到公网当中
- SQL Dialect is Not Configured (Pycharm)
- 高级算法日记8:图(1)
- 【转】各大Android应用发布市场
- 笔记:Linux下yum安装mysql5.7