# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374685 | ritul_kr_singh | Job Scheduling (CEOI12_jobs) | C++17 | 344 ms | 20972 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.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << " " <<
#define nl << "\n"
int n, d, m;
array<int, 2> a[1000000];
bool possible(int k){
int j=0;
for(int i=0; i<n; ++i){
int curr=0;
while(curr+1<=k and j<m and a[j][0]<=i+1 and i+1<=a[j][0]+d){
++j;
++curr;
}
}
return j==m;
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> d >> m;
for(int i=0; i<m; ++i) cin >> a[i][0], a[i][1] = i;
sort(a, a+m);
int low = 1, high = 1e9;
while(low<high){
int mid = (low+high)/2;
if(possible(mid)) high = mid;
else low = mid+1;
}
cout << low nl;
int j=0;
for(int i=0; i<n; ++i){
int curr=0;
while(curr+1<=low and j<m and a[j][0]<=i+1){
cout << a[j][1]+1 << ' ';
++j;
++curr;
}
cout << 0 nl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |