Submission #951617

#TimeUsernameProblemLanguageResultExecution timeMemory
951617doducanhJob Scheduling (CEOI12_jobs)C++14
0 / 100
977 ms32592 KiB
#include <bits/stdc++.h> using namespace std; #define ii pair<int,int> #define fi first #define se second const int maxn=1e5+7; vector<int>a[maxn]; vector<int>ans[maxn]; vector<int>ress[maxn]; int n,d,m; bool check(int x) { priority_queue<ii,vector<ii>,greater<ii>>q; for(int i=1;i<=n;i++)ans[i].clear(); for(int i=1;i<=n;i++){ for(int x:a[i])q.push({i,x}); while(ans[i].size()<x&&q.size()){ if(i-q.top().fi>d)return false; ans[i].push_back(q.top().se); q.pop(); } } if(q.size())return false; for(int i=1;i<=n;i++){ ress[i].clear(); for(int x:ans[i])ress[i].push_back(x); ress[i].push_back(0); } return true; } int main() { cin>>n>>d>>m; for(int i=1;i<=m;i++){ int x; cin>>x; a[x].push_back(i); } int l=0,r=1e6+7; int res=r; while(l<=r){ int m=(l+r)/2; if(check(m)){ res=m; r=m-1; } else l=m+1; } cout<<res<<"\n"; for(int i=1;i<=n;i++){ for(int x:ress[i])cout<<x<<" "; cout<<"\n"; } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'bool check(int)':
jobs.cpp:19:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         while(ans[i].size()<x&&q.size()){
      |               ~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...