Submission #703295

#TimeUsernameProblemLanguageResultExecution timeMemory
703295TAhmed33Job Scheduling (CEOI12_jobs)C++98
10 / 100
441 ms7480 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second int n, d, m; pair <int, int> arr[1000001] = {}; bool check (int x) { int pos = 1; int days = 0; while (pos <= m) { pair <int, int> dd = arr[pos]; dd.F += d; int new_pos = upper_bound(arr + 1, arr + m + 1, dd) - arr; new_pos--; new_pos = min(new_pos, m); new_pos = min(new_pos, pos + x - 1); days++; pos = new_pos + 1; } return (days <= n); } void build (int x) { int pos = 1; int days = 0; while (pos <= m) { pair <int, int> dd = arr[pos]; dd.F += d; int new_pos = upper_bound(arr + 1, arr + m + 1, dd) - arr; new_pos--; new_pos = min(new_pos, m); new_pos = min(new_pos, pos + x - 1); days++; for (int i = pos; i <= new_pos; i++) cout << arr[i].S << " "; cout << 0 << endl; pos = new_pos + 1; } while (days <= n) { cout << 0 << endl; days++; } } void cringe (int x) { for (int i = 1; i <= n; i++) cout << 0 << endl; } int main () { cin >> n >> d >> m; for (int i = 1; i <= m; i++) { cin >> arr[i].F; arr[i].S = i; } sort(arr + 1, arr + m + 1); int l = 1, r = m; int mid, ans = m; while (l <= r) { mid = (l + r) >> 1; if (check(mid)) { r = mid - 1; ans = mid; } else { l = mid + 1; } } cout << ans << endl; cringe(ans); //build(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...