Submission #1085568

#TimeUsernameProblemLanguageResultExecution timeMemory
1085568vjudge1Job Scheduling (CEOI12_jobs)C++17
100 / 100
279 ms17080 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k; vector<int>v[100001]; bool check(int x) { int t=v[1].size(),l=1; for(int i=1;i<=k;i++) { int temp=x; if(l+m<i) { return false; } while(l<=i) { if(t<=temp) { l++; temp-=t; t=v[l].size(); } else { t-=temp; break; } } } if(l!=k+1) { return false; } return true; } int main() { int a; cin>>k>>m>>n; for(int i=0;i<n;i++) { cin>>a; v[a].push_back(i+1); } int l=1,r=n; while(l<r) { int mid=(l+r)/2; if(check(mid)) { r=mid; } else { l=mid+1; } } cout<<r<<endl; l=1; int t=v[1].size(),lx=0; for(int i=1;i<=k;i++) { int temp=r; while(l<=i) { if(t<=temp) { for(int j=lx;j<v[l].size();j++) { cout<<v[l][j]<<" "; } l++; lx=0; temp-=t; t=v[l].size(); } else { for(int j=lx;j<lx+temp;j++) { cout<<v[l][j]<<" "; } lx+=temp; t-=temp; break; } } cout<<"0"<<endl; } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:68:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |                 for(int j=lx;j<v[l].size();j++)
      |                              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...