Submission #708323

#TimeUsernameProblemLanguageResultExecution timeMemory
708323Alihan_8Job Scheduling (CEOI12_jobs)C++17
100 / 100
284 ms20984 KiB
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, D, m; cin >> n >> D >> m; vector <pair<int,int>> p; for ( int i = 0; i < m; i++ ){ int x; cin >> x; p.pb({x, i}); } sort(all(p)); auto ok = [&](int x){ int i = 0, j = 0; for ( int day = 1; day <= n; day++ ){ int K = x; j = i; while ( K > 0 and j < m and p[j].first <= day ){ if ( p[j].first+D < day ) return false; j++; K--; } i = j; } return i == m; }; int l = 1, r = 1e15; while ( l < r ){ int md = (l+r) >> 1; if ( ok(md) ) r = md; else l = md+1; } cout << l << ln; int i = 0, j = 0; for ( int day = 1; day <= n; day++ ){ int K = l; j = i; while ( j < m and K > 0 and p[j].first <= day ){ cout << p[j].second+1 << ' '; j++; K--; } i = j; cout << "0\n"; } cout << '\n'; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */

Compilation message (stderr)

jobs.cpp: In function 'void IO(std::string)':
jobs.cpp:11:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:11:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...