#1051 补提交卡
来源:互联网 发布:公安局网络诈骗案 编辑:程序博客网 时间:2024/05/23 18:57
题解:开始以为是DP, 感觉特麻烦, 过程也蛮复杂的。其实可以这样想:给你n个数,可以移去其中连续的m个数, 求剩下数之间的最大差 - 1;
#include <iostream>
#include <cstdio>#include <cstring>
#include <map>
#include <algorithm>
#include <sstream>
#include <cctype>
#include <set>
#include <string>
#include <stack>
#include <vector>
using namespace std;
const int N = 105;
const int inf = 0x3f3f3f3f;
int main()
{
int t, n, m;
int a[N];
scanf("%d", &t);
while(t--)
{
scanf("%d %d", &n ,&m);
a[0] = 0;
for(int i = 1 ; i<=n; i++)
{
scanf("%d", &a[i]);
}
a[n+1] = 101;
int Maxlen = 0;
if(m>=n)
Maxlen = 100;
else
{
for(int i = 0; i <= n - m ; i++)
{
if(a[i+m+1]-a[i]-1>Maxlen)
Maxlen = a[i+m+1] - a[i]-1;
}
}
printf("%d\n", Maxlen);
}
return 0;
}
0 0
- 1051 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- 1051 : 补提交卡
- #1051 补提交卡
- #1051 : 补提交卡
- #1051 : 补提交卡
- hihoCoder:#1051 补提交卡
- hihoCoder#1051 : 补提交卡
- [HiHoCoder]#1051 : 补提交卡
- HihoCoder#1051:补提交卡
- HihoCoder 1051:补提交卡
- hihoCoder #1051 补提交卡
- hihoCoder 1051 补提交卡
- Hihocoder 1051 补提交卡
- # hihocoder #1051 补提交卡
- 学生档案管理的源码
- 学历对一个程序员来说真的那么重要吗? googleHr 表示 更看重解决问题能力
- 将cef3嵌入到mfc对话框中,当程序退出时报错,怎么解决?
- retinex算法小感
- 理顺下 linux下configure,make,make install的意义
- #1051 补提交卡
- Java求开n次方
- IDF凯撒加密
- for循环输出50到100之间的整数
- Swift 03 建造者模式 Builder Pattern
- Leetcode-24. Swap Nodes in Pairs
- Ubuntu15.10 使用手册 大量实用软件
- Javascript模块化编程(三):require.js的用法
- [从头学绘画] 第04节 身高