# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374676 | ritul_kr_singh | Job Scheduling (CEOI12_jobs) | C++17 | 409 ms | 20844 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){
for(int i=0; i<m; ++i){
int best = ((i+1)+k-1)/k;
if(best>a[i][0]+d) return false;
}
return n*k>=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 = m;
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... |