# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881267 | votranngocvy | Job Scheduling (CEOI12_jobs) | C++14 | 213 ms | 20884 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 pii pair<int,int>
#define fi first
#define se second
const int N = 1e5 + 5;
const int M = 1e6 + 5;
vector<int>vec[N];
pii a[M];
int n,d,m;
bool check(int val) {
int day = 0,cnt = 0;
for (int i = 1; i <= m; i++) {
if (cnt == val) day++,cnt = 0;
if (day < a[i].fi) day = a[i].fi,cnt = 0;
if (day > a[i].fi && day - a[i].fi > d) return false;
cnt++;
}
if (day > n) return false;
return true;
}
int tknp(int l,int r) {
int ans = r + 1;
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid)) ans = min(ans,mid),r = mid - 1;
else l = mid + 1;
}
return ans;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for (int i = 1; i <= m; i++) {
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1,a + m + 1);
int ans = tknp(1,m);
cout << ans << "\n";
int day = 0,cnt = 0;
for (int i = 1; i <= m; i++) {
if (cnt == ans) day++,cnt = 0;
if (day < a[i].fi) day = a[i].fi,cnt = 0;
vec[day].push_back(a[i].se);
cnt++;
}
for (int i = 1; i <= n; i++) {
for (auto x: vec[i]) cout << x << " ";
cout << 0 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |