Submission #232211

#TimeUsernameProblemLanguageResultExecution timeMemory
232211DodgeBallManJob Scheduling (CEOI12_jobs)C++14
100 / 100
357 ms23672 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 1e5+5; int n, m, d; vector<int> job[N], ans[N]; bool solve(int mid) { queue<pii> Q; for(int i = 1; i <= n; i++) ans[i].clear(); for(int i = 1; i <= n; i++) { for(int x : job[i]) Q.emplace(x, i); while(!Q.empty() && ans[i].size() < mid) { pii now = Q.front(); Q.pop(); if(now.y + d < i) return false; ans[i].emplace_back(now.x); } } return Q.empty(); } int main() { scanf("%d %d %d", &n, &d, &m); for(int i = 1, a; i <= m; i++) { scanf("%d", &a); job[a].emplace_back(i); } int l = 0, r = (int)1e6; while(l < r) { int mid = (l + r) >> 1; if(solve(mid)) r = mid; else l = mid + 1; } solve(r); printf("%d\n", r); for(int i = 1; i <= n; i++) { for(int x : ans[i]) printf("%d ", x); printf("0\n"); } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'bool solve(int)':
jobs.cpp:19:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(!Q.empty() && ans[i].size() < mid) {
                             ~~~~~~~~~~~~~~^~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &d, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...