Submission #466123

#TimeUsernameProblemLanguageResultExecution timeMemory
466123nehasaneJob Scheduling (CEOI12_jobs)C++14
10 / 100
473 ms13724 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, d, m; cin >> n >> d >> m; vector <pair<int, int>> jobs(m); for (int i = 0; i < m; i++){ cin >> jobs[i].first; jobs[i].second = i; } sort(begin(jobs), end(jobs)); int l = 1, r = m; while (l <= r){ int mid = (l+r) / 2; int day = 1, i = 0, start = 0; for (day; day <= n && i < m; day++){ for (i; i < min(m, start + mid); i++){ if (jobs[i].first + d < day && jobs[i].first >= day){ start = INT_MAX; break; } } if (start == INT_MAX) break; else start = i; } if (start == INT_MAX || i < m) l = mid + 1; else r = mid - 1; } cout << l << '\n'; int i = 0; for (int day = 0; day < n; day++){ int end = i + l; for (i; i < min(m, end); i++) cout << jobs[i].second + 1 << ' '; cout << 0 << '\n'; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:17:14: warning: statement has no effect [-Wunused-value]
   17 |         for (day; day <= n && i < m; day++){
      |              ^~~
jobs.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 |             for (i; i < min(m, start + mid); i++){
      |                  ^
jobs.cpp:38:14: warning: statement has no effect [-Wunused-value]
   38 |         for (i; i < min(m, end); i++)
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...