Submission #374676

#TimeUsernameProblemLanguageResultExecution timeMemory
374676ritul_kr_singhJob Scheduling (CEOI12_jobs)C++17
55 / 100
409 ms20844 KiB
//#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 timeMemoryGrader output
Fetching results...