#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
int main() {
int n, d, m;
cin >> n >> d >> m;
vector<int> nums(n);
map<int, vector<int>> cows;
for (int i = 0; i < m; i++) {
int temp;
cin >> temp;
temp--;
nums[temp]++;
cows[temp].push_back(i + 1);
}
int lo = 0;
int hi = 1000005;
while (lo < hi) {
int mid = (lo + hi) / 2;
vector<int> temp = nums;
int idx = 0;
bool bad = false;
for (int i = 0; i < n; i++) {
if (idx + d < i && idx != n - d) {
bad = true;
break;
}
int tCounter = mid;
while (idx <= i && tCounter > 0) {
if (idx == n - d) {
break;
}
if (temp[idx] > tCounter) {
temp[idx] -= tCounter;
break;
}
else {
tCounter -= temp[idx];
temp[idx] = 0;
idx++;
}
}
}
if (!bad) {
hi = mid;
}
else {
lo = mid + 1;
}
}
cout << hi << endl;
/*
int ans = 0;
int countDays = 0;
for (int i = 0; i < n; i++) {
for (auto p : cows[i]) {
cout << p << " ";
ans++;
if (ans == hi) {
ans = 0;
cout << 0 << endl;
countDays++;
}
}
}
for (int i = 0; i < n - countDays; i++) {
cout << 0 << endl;
}
*/
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1012 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
31 ms |
1012 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
30 ms |
1012 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
28 ms |
1148 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
29 ms |
1020 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
28 ms |
1020 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
29 ms |
1016 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
28 ms |
1020 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
31 ms |
1792 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
31 ms |
1784 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
40 ms |
1016 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
79 ms |
1400 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
121 ms |
2552 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
227 ms |
4088 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
198 ms |
3448 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
331 ms |
5496 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
374 ms |
6648 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
329 ms |
4984 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
364 ms |
5628 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
393 ms |
6680 KB |
Unexpected end of file - int32 expected |