# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532897 | raypeng1729 | Job Scheduling (CEOI12_jobs) | C++17 | 260 ms | 21672 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 all(v) v.begin(), v.end()
const int N = 2e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;
#define X first
#define Y second
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
int n, d, m; cin >> n >> d >> m;
pair<int, int> p[m];
for(int i = 0; i < m; i++){
cin >> p[i].first; p[i].second = i + 1;
}
sort(p, p + m);
int l = 0, r = INF;
vector<int> work(n);
while(r - l > 1){
int mid = l + r >> 1;
int pos = 0;
bool ok = 1;
for(int i = 0; i < n; i++){
int cnt = 0;
while(pos < m && cnt < mid && p[pos].first <= i + 1) pos++, cnt++;
work[i] = cnt;
if(pos < m && p[pos].first < i - d) ok = 0;
}
if(pos < m) ok = 0;
if(ok) r = mid;
else l = mid;
}
int pos = 0;
cout << r << '\n';
for(int i : work){
while(i--){
cout << p[pos].second << ' ', pos++;
} cout << "0\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |