#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define trav(a, x) for(auto& a : x)
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define ROF(i, a, b) for (int i=(a); i>=(signed)(b); i--)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define vi vector<int>
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
typedef long long ll;
const int mod = 1e9 + 7, MOD = 998244353;
const int N = 2005;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, d;
cin >> n >> d >> m;
vector<int> v(m);
vector<vector<int>> tind(n-d+1);
F0R(i, m) {
cin >> v[i];
tind[v[i]].push_back(i);
}
int hi = m, lo = 0;
while(hi - lo > 1) {
int mid = (hi+lo)/2;
bool ok = true;
int c = 0;
FOR(i, 1, n-d) {
if(c + (int)tind[i].size() > mid * (d+1)) {
ok = false;
break;
}
c = max(0, c+(int)tind[i].size()-mid);
}
//cout << mid << '\n';
if(ok) hi=mid;
else lo=mid;
}
cout << hi;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1624 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
8 ms |
1732 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
7 ms |
1756 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
10 ms |
1624 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
7 ms |
1752 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
7 ms |
1752 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
7 ms |
1752 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
7 ms |
1644 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
10 ms |
3776 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
10 ms |
3816 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
9 ms |
1452 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
17 ms |
2256 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
27 ms |
3868 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
39 ms |
4860 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
37 ms |
5452 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
56 ms |
6964 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
65 ms |
8604 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
66 ms |
8268 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
74 ms |
10728 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
90 ms |
8520 KB |
Unexpected end of file - int32 expected |