Submission #568661

#TimeUsernameProblemLanguageResultExecution timeMemory
568661gcconureJob Scheduling (CEOI12_jobs)C++17
5 / 100
385 ms65536 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n,d,m; vector<pair<ll,ll>> v; vector<vector<ll>> arr; bool ok(ll dd){ auto copy=v; arr.clear(); for(ll i = 0; i < n; i++){ arr.push_back({}); } ll day = 0; ll done=0; bool works=true; while(done<m){ if(day==n){ works=false; break; } for(ll i = 0; i < min(ll(v.size()+1),ll(dd)); i++){ arr[day].push_back(v.back().second); v.pop_back(); } day++; done+=dd; } v=copy; return works; } int main(){ cin >> n >> d >> m; for(ll i = 0; i < m; i++){ ll x; cin >> x; v.push_back({x,i}); } sort(v.rbegin(), v.rend()); ll l = 1,r=m; vector<vector<ll>> cur; while(l<r){ ll mid = (l+r)/2; if(ok(mid)){ cur=arr; r=mid; } else{ l=mid+1; } } cout << l << "\n"; for(vector<ll> vv:cur){ for(ll i:vv){ cout << i+1 << " "; } cout << 0 << "\n"; } for(ll i = 0; i < n-cur.size(); i++){ cout << 0 << "\n"; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:67:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'long long unsigned int' [-Wsign-compare]
   67 |     for(ll i = 0; i < n-cur.size(); i++){
      |                   ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...