Submission #165955

#TimeUsernameProblemLanguageResultExecution timeMemory
165955redaJob Scheduling (CEOI12_jobs)C++14
100 / 100
640 ms16888 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> #define fi first #define se second #define endl '\n' int n , m , d; const int MAXN = 1e5 +7 ; vector<int> adj[MAXN]; bool bs(int mid , bool h ) { queue<pii> q; for(int i = 1 ;i <=n;i++){ for(auto j : adj[i]) q.push({i,j}); for(int j = 0 ;j <mid && q.size() ;j++) { if(i-q.front().fi >d)return 0; if(h)cout<<q.front().se<<' '; q.pop(); } if(h) cout<<'0'<<endl; } return 1 ; } int main () { cin >> n >> d >> m; for(int i = 1 ;i <= m ;i++) { int h ; cin>>h; adj[h].pb(i); } int l = 1 , r = m ; while(l!=r) { int mid = (l+r)/2; if(bs(mid,0))r=mid; else l =mid+1; } cout<<l<<endl; bs(l,1); return 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...