Submission #466113

#TimeUsernameProblemLanguageResultExecution timeMemory
466113nehasaneJob Scheduling (CEOI12_jobs)C++14
15 / 100
449 ms13732 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 = 0, i = 0, start = 0; while (i < m){ for (i; i < min(m, start+mid); i++){ if (day > jobs[i].first + d){ start = INT_MAX; break; } } if (start == INT_MAX) break; else start = i; day++; } if (start == INT_MAX || day > n) 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:18:18: warning: statement has no effect [-Wunused-value]
   18 |             for (i; i < min(m, start+mid); i++){
      |                  ^
jobs.cpp:39:14: warning: statement has no effect [-Wunused-value]
   39 |         for (i; i < min(m, end); i++)
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...