Submission #899646

#TimeUsernameProblemLanguageResultExecution timeMemory
899646ivazivaJob Scheduling (CEOI12_jobs)C++14
100 / 100
340 ms28200 KiB
#include <bits/stdc++.h> using namespace std; long long n,d,m; vector<pair<pair<long long,long long>,long long>> vec; bool check(long long mid) { long long dan=1; bool da=true; long long poz=0; while (dan<=n) { if (!da) break; long long br=1; while (br<=mid and poz<vec.size()) { long long pocetak=vec[poz].first.first; long long kraj=vec[poz].first.second; if (dan>=pocetak and dan<=kraj) {poz++;br++;} else if (dan>kraj) {da=false;break;} else if (dan<pocetak) break; } dan++; } return da; } void resenje(long long rez) { long long dan=1; long long poz=0; while (dan<=n) { long long br=1; while (br<=rez and poz<vec.size()) { long long pocetak=vec[poz].first.first; long long kraj=vec[poz].first.second; if (dan>=pocetak and dan<=kraj) { cout<<vec[poz].second<<" "; poz++;br++; } else if (dan<pocetak) break; } cout<<0<<endl;dan++; } } int main() { ios_base::sync_with_stdio(false); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>d>>m; for (long long i=1;i<=m;i++) { long long x; cin>>x; vec.push_back({{x,x+d},i}); } sort(vec.begin(),vec.end()); long long l=1; long long r=m; long long rez=-1; while (l<=r) { long long mid=(l+r)/2; if (check(mid)) {rez=mid;r=mid-1;} else l=mid+1; } cout<<rez<<endl; resenje(rez); }

Compilation message (stderr)

jobs.cpp: In function 'bool check(long long int)':
jobs.cpp:17:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         while (br<=mid and poz<vec.size())
      |                            ~~~^~~~~~~~~~~
jobs.cpp: In function 'void resenje(long long int)':
jobs.cpp:37:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while (br<=rez and poz<vec.size())
      |                            ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...