Submission #742787

#TimeUsernameProblemLanguageResultExecution timeMemory
742787joesephdiverJob Scheduling (CEOI12_jobs)C++17
0 / 100
363 ms15772 KiB
#include <bits/stdc++.h> #define ll long long #define FOR(x, n) for(int x = 0; x < n; x++) #define LFOR(x, l, r) for(int x = l; x < r; x++) #define last(x) x[x.size()-1] #define negind(x, i) x[x.size()-i] #define pii pair<int, int> #define ins insert #define pb push_back #define pf push_front #define s(x) set(x) #define v(x) vector<x> #define uom(x, y) unordered_map<x, y> #define triplet(x) tuple<x, x, x> #define all(x) x.begin(), x.end() #define inf INT_MAX using namespace std; inline void solve(){ int N, D, M; cin >> N >> D >> M; pii a[M]; FOR(i, M){ cin >> a[i].first; a[i].second = i+1; } sort(a, a+M); int l = 1, r = 1000000, sol; while(l <= r){ int mid = l + (r-l)/2, index = mid-1, day = 1, delay = 0; while(index < M){ delay = max(delay, day-a[index].first); day++; FOR(i, mid){ if(index >= M || a[index+1].first > day) break; index++; } } if(delay <= D) sol = mid, r = mid - 1; else l = mid+1; } cout << sol << endl; int index = 0; while(index < M){ LFOR(i, index, min(M, index+sol)) cout << a[i].second << " "; index += sol; cout << "0\n"; } FOR(i, N-ceil((double)M/sol)) cout << "0\n"; } int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); return 0; }

Compilation message (stderr)

jobs.cpp: In function 'void solve()':
jobs.cpp:50:15: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |  FOR(i, N-ceil((double)M/sol)) cout << "0\n";
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...