Submission #1027041

#TimeUsernameProblemLanguageResultExecution timeMemory
1027041kkkkkkkkJob Scheduling (CEOI12_jobs)C++14
100 / 100
203 ms26924 KiB
#include <bits/stdc++.h> using namespace std; int n, d, m; vector<pair<int,int> > v; vector<vector<int> > rez; bool ok(int masini) { int baranje=0; vector<vector<int> > raspored(n+1); for (int den=1;den<=n;den++) { for (int i=0;i<masini;i++) { if (v[baranje].first>den) break; if (v[baranje].first+d<den) return false; raspored[den].push_back(v[baranje].second); baranje++; if (baranje==m) { rez=raspored; return true; } } } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> d >> m; v.resize(m); for (int i=0;i<m;i++) { cin >> v[i].first; v[i].second=i+1; } sort(v.begin(), v.end()); int l=0, r=m; while (l+1<r) { int mid=(l+r)/2; if (ok(mid)) r=mid; else l=mid; } cout << r << '\n'; for (int i=1;i<rez.size();i++) { for (auto x:rez[i]) cout << x << " "; cout << "0" << '\n'; } return 0; }

Compilation message (stderr)

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