Submission #1050739

#TimeUsernameProblemLanguageResultExecution timeMemory
1050739vjudge1Job Scheduling (CEOI12_jobs)C++17
0 / 100
153 ms17308 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pld pair<ld, ld> #define pb push_back #define fi first #define se second #define debug(x) cout << #x << " => " << x << endl #define all(x) x.begin(),x.end() int n,d,m; pii a[1000010]; bool ok(int x) { int t=0,i=0,cnt=0,mx=0; while(i<m) { while(i<m && cnt<x && a[i].fi<=t) i++,cnt++,mx=max(mx,t+d); cnt=0; t++; } return mx<=n; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>d>>m; for(int i=0;i<m;i++) cin>>a[i].fi; for(int i=0;i<m;i++) a[i].se=i; sort(a,a+m); int l=1,r=m,ans=m; while(l<=r) { int mid=(l+r)/2; if(ok(mid)) r=mid-1,ans=mid; else l=mid+1; } cout<<ans<<'\n'; int t=1,i=0,cnt=0; while(i<m) { while(i<m && cnt<ans && a[i].fi<=t) { cout<<a[i].se+1<<' '; i++,cnt++; } cnt=0; t++; cout<<"0\n"; } while(t<=n) { t++; cout<<"0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...