Submission #1027948

#TimeUsernameProblemLanguageResultExecution timeMemory
1027948vjudge1Job Scheduling (CEOI12_jobs)C++17
40 / 100
221 ms26920 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, docnenje, m; cin>>n>>docnenje>>m; pair<int, int>a[m]; for(int i=0; i<m; i++) { cin>>a[i].first; a[i].second=i; } sort(a, a+m); int l=0, r=m-1; vector<vector<int>>sol(n+1); while(r-l>1) { vector<vector<int>>rez(n+1); int mid=(l+r)/2; int index=0; bool kiki1=0; bool found=0; for(int i=1; i<=n && !found; i++) { bool kiki=0; for(int j=0; j<mid; j++) { if(a[index].first+docnenje<i) { kiki=1; break; } if(a[index].first>i) break; index++; rez[i].push_back(a[index].second); if(index==m) { sol=rez; found=1; break; } } if(kiki) { kiki1=1; break; } } if(kiki1) l=mid; else r=mid; } cout<<r<<"\n"; for(int i=1; i<=n; i++) { for(int j=0; j<sol[i].size(); j++) cout<<sol[i][j]+1<<" "; cout<<"0\n"; } return 0; }

Compilation message (stderr)

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