# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091097 | andro | Job Scheduling (CEOI12_jobs) | C++17 | 94 ms | 8176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |