Submission #716082

#TimeUsernameProblemLanguageResultExecution timeMemory
716082SnowRaven52Job Scheduling (CEOI12_jobs)C++17
0 / 100
3 ms600 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; int main() { freopen("input.in", "r", stdin); cin.tie(0)->sync_with_stdio(false); int n, d, m; cin >> n >> d >> m; vector<pair<int, int>> t(m); for (int i = 0; i < m; i++) { cin >> t[i].first; t[i].second = i + 1; } sort(t.begin(), t.end()); vector<vector<int>> res; int l = 0, r = m; while (l + 1 < r) { int mid = l + (r - l) / 2; vector<vector<int>> cur(n + 1); vector<int> q; for (int i = 0; i < mid; i++) { q.push_back(0); } bool works = true; for (int i = 0; i < m; i++) { if (q[0] - d <= t[i].first) { int jt = max(q[0], t[i].first); q.push_back(jt + 1); cur[jt].push_back(t[i].second); q.erase(q.begin()); } else { works = false; break; } } if (works) { r = mid; res = cur; } else { l = mid; } } cout << r << endl; for (int i = 1; i <= n; i++) { for (int x : res[i]) { cout << x << " "; } cout << 0 << endl; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen("input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...