Submission #746269

#TimeUsernameProblemLanguageResultExecution timeMemory
746269hasan_tawsifJob Scheduling (CEOI12_jobs)C++14
55 / 100
309 ms20576 KiB
#include <bits/stdc++.h> using namespace std; using LL = long long; void solve() { int n, d, m; cin >> n >> d >> m; vector<pair<int, int > > v; for (int i = 0; i < m; ++i) { int x; cin >> x; v.push_back({x, i + 1}); } sort(v.begin(), v.end()); // for (auto [u, x] : v) cerr << u << " " << x << endl; int lo = 1, hi = m; vector<int> ans[n + 1]; auto test = [&] (int numOfMachine) { int cur = 0, day = 1, tot = 0; for (auto [u, x] : v) { if (day == u or day - u <= d) { tot++; cur++; } else return false; cur %= numOfMachine; if (cur == 0) day++; } return tot == m; }; while (lo < hi) { int mid = lo + (hi - lo) / 2; if (test(mid)) hi = mid; else lo = mid + 1; } int cur = 0, day = 1, tot = 0; for (auto [u, x] : v) { if (day == u or day - u <= d) { ans[day].push_back(x); tot++; cur++; } cur %= hi; if (cur == 0) day++; } cout << hi << "\n"; for (int i = 1; i <= n; ++i) { for (auto u : ans[i]) cout << u << " "; cout << "0\n"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) solve(); }

Compilation message (stderr)

jobs.cpp: In lambda function:
jobs.cpp:19:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |   for (auto [u, x] : v) {
      |             ^
jobs.cpp: In function 'void solve()':
jobs.cpp:35:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |  for (auto [u, x] : v) {
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...