# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374874 | Aryan_Raina | Job Scheduling (CEOI12_jobs) | C++14 | 410 ms | 22572 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;
#define int long long
#define ld long double
#define ar array
const int INF = 1e15;
const int MOD = 1e9+7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m; cin>>n>>d>>m;
vector<ar<int,2>> a(m);
for (int i = 0; i < m; i++) {
cin>>a[i][0]; a[i][1] = i+1;
}
sort(a.begin(), a.end());
auto check = [&](int x) {
if ((m+x-1)/x >= n) return false;
vector<int> time(x, 0);
for (int i = 0; i < m; i++) {
if (time[i % x] - a[i][0] >= d) return false;
time[i % x] = max(time[i % x], a[i][0]) + 1;
}
return true;
};
int lo = 0, hi = m, mid;
while (lo + 1 < hi) {
mid = (lo + hi)>>1;
if (check(mid)) hi = mid;
else lo = mid;
}
cout<<hi<<"\n";
for (int i = 0, j = 0; i < n; i++) {
for (int k = j; j < min(k+hi,m); j++) cout<<a[j][1]<<" ";
cout<<"0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |