Submission #515761

#TimeUsernameProblemLanguageResultExecution timeMemory
515761mzhJob Scheduling (CEOI12_jobs)C++17
0 / 100
246 ms21496 KiB
#include <bits/stdc++.h>
using namespace std;

// 1 1 2 2 2 3 3 4 4 5 6 6

int main() {
#ifdef LOCAL
  freopen("input.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  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());
  int l = 0, r = m;
  while (l + 1 < r) {
    int mid = l + (r - l) / 2;
    queue<int> q;
    for (int i = 0; i < mid; i++) {
      q.push(0);
    }
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (q.front() - d <= t[i].first) {
        q.push(max(q.front(), t[i].first) + 1);
        q.pop();
      } else {
        ok = false;
        break;
      }
    }
    (ok ? r : l) = mid;
  }
  cout << r << '\n';
  int id = 0;
  for (int i = 0; i < n; i++) {
    int c = 0;
    while (id < m && c < r) {
      cout << t[id + c++].second << ' ';
    }
    id += c;
    cout << "0\n";
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...