Submission #498183

#TimeUsernameProblemLanguageResultExecution timeMemory
498183AmirElarbiJob Scheduling (CEOI12_jobs)C++14
0 / 100
1 ms284 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 1e9 #define eps 1e-7 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 #define V 450 using namespace std; const int MOD = 1e9+7; const int nax = 200005; int n,d,m; vii s; int main(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); cin >> n >> d >> m; for (int i = 0; i < m; ++i) { int a; cin >> a; s.pb({a,i}); } sort(s.begin(), s.end()); int l = 1, r = m+1; while(l < r){ int md=(l+r)/2; int done = 0; for (int i = 1; i <= n; ++i) { if(done == m) break; if(i-s[done+1].fi > d){ done = -1; break; } int p = upper_bound(s.begin(), s.end(),mp(i,(int)(1e7)))-s.begin(); done += min(p-done,md); } if(done == m){ r = md; } else { l = md + 1; } } int res = (l+r)/2; cout << res << endl; int done = -1; for (int i = 1; i <= n; ++i) { if(done == m){ cout << 0 << endl; } else { int p = upper_bound(s.begin(), s.end(),mp(i,(int)(1e7)))-s.begin(); for (int i = done+1; i <= min(min(p,res+done),m-1); ++i) { cout << s[i].se+1 << " "; } cout << 0 << endl; done += min(p-done,res); //cout << done << " " << p-done << endl; } } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:28:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...