Submission #882375

#TimeUsernameProblemLanguageResultExecution timeMemory
882375vjudge1Job Scheduling (CEOI12_jobs)C++14
30 / 100
206 ms25080 KiB
#include <bits/stdc++.h> using namespace std; #define _for(i, a, b) for(LL i = (a); i <= (b); ++i) using LL = long long; const int MM = 1E6 + 5, NN = 1E5 + 5; LL n, m, d, D[MM]; vector<LL> B[NN]; bool wk(LL x, LL op){//op为0则不输出方案,op为1则输出方案 queue<array<LL, 2>> Q; _for(i, 1, n){ LL t = x; while(!Q.empty() && t){ auto f = Q.front(); if(f[1] + d < i) return 0; if(op == 1) printf("%d ", f[0]); Q.pop(), --t; } if(!Q.empty() && Q.front()[1] + d < i) return 0; for(LL j = 0; j < B[i].size(); ++j) if(t && (--t, op == 1)) printf("%d ", B[i][j]); else Q.push({B[i][j], i}); if(op == 1) puts("0"); } return 1; } int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> d >> m; _for(i, 1, m) cin >> D[i], B[D[i]].push_back(i); LL l = 1, r = m, mid; while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1); return printf("%d\n", r + 1), wk(r + 1, 1), 0; }

Compilation message (stderr)

jobs.cpp: In function 'bool wk(LL, LL)':
jobs.cpp:15:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::array<long long int, 2>::value_type' {aka 'long long int'} [-Wformat=]
   15 |    if(op == 1) printf("%d ", f[0]);
      |                        ~^
      |                         |
      |                         int
      |                        %lld
jobs.cpp:19:19: warning: comparison of integer expressions of different signedness: 'LL' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(LL j = 0; j < B[i].size(); ++j)
      |                 ~~^~~~~~~~~~~~~
jobs.cpp:20:37: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
   20 |    if(t && (--t, op == 1)) printf("%d ", B[i][j]);
      |                                    ~^
      |                                     |
      |                                     int
      |                                    %lld
jobs.cpp: In function 'int main()':
jobs.cpp:31:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |  while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1);
      |                          ~~^~~
jobs.cpp:32:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'LL' {aka 'long long int'} [-Wformat=]
   32 |  return printf("%d\n", r + 1), wk(r + 1, 1), 0;
      |                 ~^     ~~~~~
      |                  |       |
      |                  int     LL {aka long long int}
      |                 %lld
#Verdict Execution timeMemoryGrader output
Fetching results...