Submission #920229

#TimeUsernameProblemLanguageResultExecution timeMemory
920229KavelmydexJob Scheduling (CEOI12_jobs)C++17
75 / 100
226 ms46752 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define vi vector<int> #define rep(i,x,n) for(int i=x; i<n; ++i) #define For(i,n) rep(i,0,n) #define pb push_back #define f first #define s second #define endl "\n" #define sp ' ' // #define sz size() #define all(x) (x).begin(),(x).end() const int N = 1e5+10, OO = 1e18, mod = 1e9+7; void tr(int a, int b){cout << a << sp << b << endl;} vi a[N], ans[N], cur[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int n,d,m; cin >> n >> d >> m; For(i,m){ int x; cin >> x; a[x].pb(i+1); } int l=0, r = 1e7; while(r > l+1){ int mid = (l+r)/2, ok = 1; deque <pi> v; rep(i,1,n+1) cur[i].clear(); rep(i,1,n+1){ int sz = v.size(); For(j, min(mid, sz)){ if(i-v.front().s > d) ok = 0; cur[i].pb(v.front().f); v.pop_front(); } int c = a[i].size(), ava = mid - min(mid,sz); for(int j=0; j < c; ++j){ if(j < ava) cur[i].pb(a[i][j]); else v.pb({a[i][j],i}); } } if(ok){ r = mid; rep(i,1,n+1) ans[i] = cur[i]; } else l = mid; } cout << r << endl; rep(i,1,n+1){ for(int j: ans[i]) cout << j << sp; cout << 0 << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...