Submission #638265

#TimeUsernameProblemLanguageResultExecution timeMemory
638265NONTACJob Scheduling (CEOI12_jobs)C++11
10 / 100
691 ms43236 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int n,m,d; ii a[1000000]; vector<vector<int> > ans; bool check(int x) { int j=0; vector<vector<int> > days(n+1); for(int i=1;i<=n;i++){ int cnt=x; if(a[j].first> i+d) return false; while(cnt && a[j].first <= i+d){ cnt--; days[i].push_back(a[j].second+1); j++; if(j==m){ ans.assign(days.begin(),days.end()); return true; } } } return false; } int last_true() { int lo=1, hi=m; while(lo<hi){ int mid=lo + (hi-lo)/2; if(check(mid)){ hi=mid; } else{ lo=mid+1; } } check(lo); return lo; } int main() { //freopen("test.in","r",stdin); //freopen("test.out","w",stdout); cin>>n>>d>>m; for(int i=0;i<m;i++){ cin>>a[i].first; a[i].second=i; } sort(a,a+m); cout<<last_true()<<endl; for(int i=1;i<=n;i++){ for(int j=0;j<ans[i].size();j++) cout<<ans[i][j]<<" "; cout<<0<<endl; } return 0; }

Compilation message (stderr)

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