不会做。。题意就是给定一个区间,每次去除一个点,要求剩下的区间可以放k个长度为a的区间~
AC代码:
#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "set"
using namespace std;
int n, m, k, a;
set<int> s;
int main(int argc, char const *argv[])
{
cin >> n >> k >> a >> m;
s.clear();
int sum = (n + 1) / (a + 1);
s.insert(0);
s.insert(n + 1);
int ans = -1;
bool flag = false;
for(int i = 1; i <= m; ++i) {
int b;
cin >> b;
set<int>::iterator it = s.upper_bound(b);
int y = *it, x = *(--it);
sum -= (y - x) / (a + 1) - (y - b) / (a + 1) - (b - x) / (a + 1);
if(sum < k && !flag) {
ans = i;
flag = true;
}
s.insert(b);
}
cout << ans << endl;
return 0;
}