Submission #113334

#TimeUsernameProblemLanguageResultExecution timeMemory
113334KastandaJob Scheduling (CEOI12_jobs)C++11
5 / 100
231 ms16760 KiB
#include<bits/stdc++.h> using namespace std; const int N = 100005; int n, d, q, qu[N * 10]; vector < int > A[N]; inline bool Solve(int md, bool fnl = 0) { if (fnl) printf("%d\n", md); int l = 0, r = 0; for (int i = 1; i <= n; i++) { if (r - l && qu[l] < i - d) return 0; for (int id : A[i]) qu[r ++] = id; for (int j = 0; j < md && l < r; j++) { if (fnl) printf("%d ", qu[l]); l ++; } if (fnl) printf("0\n"); } if (r - l) return 0; return 1; } int main() { scanf("%d%d%d", &n, &d, &q); for (int i = 1, a; i <= q; i++) scanf("%d", &a), A[a].push_back(i); int le = 0, ri = q, md; while (ri - le > 1) { md = (le + ri) >> 1; if (Solve(md)) ri = md; else le = md; } Solve(ri, 1); return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &d, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a), A[a].push_back(i);
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...