Submission #1166131

#TimeUsernameProblemLanguageResultExecution timeMemory
1166131beheshtJob Scheduling (CEOI12_jobs)C++20
8 / 100
335 ms70168 KiB
#include <bits/stdc++.h> #define ld long double #define ll long long #define pb push_back #define mk make_pair #define S second #define Y second #define F first #define X first #define arr(x) array <int, x> #define debug(x) cout << #x << " : " << x << endl << flush #define _debug(x, y, z) cout << #x << " : " << x << " " << #y << " : " << y << " " << #z << " : " << z << endl << flush #define __debug(x, y, z, a) cout << #x << " : " << x << " " << #y << " : " << y << " " << #z << " : " << z << " "<< #a << " : " << a << endl << flush #define endl '\n' #define int long long using namespace std; const int INF = 1e9 + 24 + (11/10); const int MAXN = 1e6 + 24 + (11/10); int a[MAXN]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, d, m; cin >> n >> d >> m; for(int i = 0; i < m; i++) cin >> a[i]; sort(a, a + m); int l = 0, r = m, mid; while(r - l > 1){ mid = (r + l) >> 1; int cnt = 0; int day = 1; for(int i = 0; i < m; i++){ int x = a[i]; if(x > day){ day = x; cnt = 1; } else if(cnt == mid){ cnt = 1; day++; } else cnt++; } if(day <= n) r = mid; else l = mid; } multiset <arr(2)> s; for(int i = 0; i < m; i++){ s.insert({a[i], i + 1}); } int day = 1; int cnt = 0; cout << r << endl; while(!s.empty()){ auto [x, ind] = *s.begin(); s.erase(s.begin()); if(x > day){ for(int i = 0; i < x - day; i++) cout << 0 << endl; day = x; cnt = 1; } else if(cnt == r){ cnt = 1; day++; cout << 0 << endl; } else cnt++; cout << ind << " "; } for(int i = 0; i < n - day + 1; i++) cout << 0 << endl; } // Man hamooonam ke ye rooz...
#Verdict Execution timeMemoryGrader output
Fetching results...