题目:点击进入
描述:
一个1到100的数列有n个地方是断开的,现给出这n个位置以及一个数m,表示可以使m个位置连续,求可以得到的最长的连续区间的长度,n个位置按照升序给出。
题解:
将起点和终点补充进去之后,必须使这m个位置连续地消除才能使最终长度最长,所以直接枚举这m个位置的左端点即可。
代码:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <cassert>
#include <cctype>
#include <complex>
#include <algorithm>
#include <string>
#include <iostream>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
using namespace std;
#define fi first
#define se second
#define MP(A, B) make_pair(A, B)
#define pb push_back
#define gcd __gcd
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
typedef long long ll;
typedef unsigned long long ulls;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef