Submission #905047

# Submission time Handle Problem Language Result Execution time Memory
905047 2024-01-12T13:26:08 Z gun_gan Job Scheduling (CEOI12_jobs) C++17
0 / 100
81 ms 924 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 1e6 + 5;
int N, M, D;
int cnt[MX];

bool f(int x) {
      deque<int> dq;
      for(int i = 1; i <= N; i++) {
            if(dq.size() && dq.front() < i) return 0;
            for(int j = 0; j < cnt[i]; j++) dq.push_back(i + D);
            for(int j = 0; j < x; j++) {
                  if(dq.empty()) break;
                  dq.pop_front();
            }
      }     

      if(dq.size()) return 0;
      return 1;
}

// void p(int x) {
//       deque<int> dq;
//       for(int i = 1; i <= N; i++) {
//             for(int j = 0; j < cnt[i]; j++) dq.push_back(i + D);
//             for(int j = 0; j < x; j++) {
//                   if(dq.empty()) break;
//                   dq.pop_front();
//             }
//       }     
// }

int main() {
      cin.tie(0); ios_base::sync_with_stdio(0);

      cin >> N >> D >> M;
      for(int i = 0; i < M; i++) {
            int x;
            cin >> x;
            cnt[x]++;
      }

      int l = 1, r = M, ans = 0;
      while(l <= r) {
            int mid = (l + r) >> 1;
            if(f(mid)) {
                  r = mid - 1, ans = mid;
            } else {
                  l = mid + 1;
            }
      }

      cout << ans << '\n';
      // p(ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 888 KB Unexpected end of file - int32 expected
2 Incorrect 11 ms 876 KB Unexpected end of file - int32 expected
3 Incorrect 9 ms 876 KB Unexpected end of file - int32 expected
4 Incorrect 9 ms 924 KB Unexpected end of file - int32 expected
5 Incorrect 10 ms 876 KB Unexpected end of file - int32 expected
6 Incorrect 9 ms 876 KB Unexpected end of file - int32 expected
7 Incorrect 9 ms 876 KB Unexpected end of file - int32 expected
8 Incorrect 9 ms 872 KB Unexpected end of file - int32 expected
9 Incorrect 11 ms 464 KB Unexpected end of file - int32 expected
10 Incorrect 11 ms 348 KB Unexpected end of file - int32 expected
11 Incorrect 9 ms 600 KB Unexpected end of file - int32 expected
12 Incorrect 20 ms 348 KB Unexpected end of file - int32 expected
13 Incorrect 23 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 35 ms 592 KB Unexpected end of file - int32 expected
15 Incorrect 48 ms 348 KB Unexpected end of file - int32 expected
16 Incorrect 47 ms 348 KB Unexpected end of file - int32 expected
17 Incorrect 58 ms 504 KB Unexpected end of file - int32 expected
18 Incorrect 63 ms 344 KB Unexpected end of file - int32 expected
19 Incorrect 81 ms 352 KB Unexpected end of file - int32 expected
20 Incorrect 58 ms 504 KB Unexpected end of file - int32 expected