#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int m, d, n;
cin >> m >> d >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a.begin() + 1, a.end());
int l = 1, r = n, ans = - 1;
vector<int> br(m + 1, 0);
for(int i = 1; i <= n; i++) {
br[a[i]] += 1;
}
while(l <= r) {
int mid = (l + r) / 2;
int p = 1;
int ok = 1;
int t = a[p];
int koji = 1;
vector<int> posetio(m + 1, 0);
while(p <= n) {
if(posetio[a[p]]) {
p += 1;
continue;
}
posetio[a[p]] = 1;
int treba = br[a[p]] / mid;
if(br[a[p]] % mid) {
treba += 1;
}
if(treba > d) {
ok = 0;
break;
}
p += 1;
}
if(ok) {
r = mid - 1;
ans = mid;
}
else {
l = mid + 1;
}
for(int i = 0; i <= m; i++) {
posetio[i] = 0;
}
}
cout << ans;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:24:13: warning: unused variable 't' [-Wunused-variable]
24 | int t = a[p];
| ^
jobs.cpp:25:13: warning: unused variable 'koji' [-Wunused-variable]
25 | int koji = 1;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1368 KB |
Output isn't correct |
2 |
Incorrect |
6 ms |
1120 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
1116 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
1156 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
1120 KB |
Output isn't correct |
6 |
Incorrect |
5 ms |
1120 KB |
Output isn't correct |
7 |
Incorrect |
9 ms |
1120 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
1052 KB |
Output isn't correct |
9 |
Incorrect |
12 ms |
1888 KB |
Output isn't correct |
10 |
Incorrect |
9 ms |
1884 KB |
Output isn't correct |
11 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct |
12 |
Incorrect |
20 ms |
1884 KB |
Output isn't correct |
13 |
Incorrect |
28 ms |
2648 KB |
Output isn't correct |
14 |
Incorrect |
47 ms |
3928 KB |
Output isn't correct |
15 |
Incorrect |
50 ms |
4188 KB |
Output isn't correct |
16 |
Incorrect |
88 ms |
5620 KB |
Output isn't correct |
17 |
Incorrect |
81 ms |
6488 KB |
Output isn't correct |
18 |
Incorrect |
76 ms |
6480 KB |
Output isn't correct |
19 |
Incorrect |
94 ms |
8176 KB |
Output isn't correct |
20 |
Incorrect |
83 ms |
6528 KB |
Output isn't correct |