Submission #18745392


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll N; cin >> N;
  ll M; cin >> M;
  if (M == 0) {
    cout << 1 << '\n';
    return 0;
  }

  vector<ll> A(M + 2); for (ll i = 0; i < M; i++) cin >> A[i];
  A[M] = N + 1;
  A[M + 1] = 0;
  sort(A.begin(), A.end());

  ll l = 1, r = N;
  ll ans = N - M;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    ll i = 0;
    ll cnt = 0;
    bool ok = true;
    for (ll i = 0; i < M + 1; i++) {
      ll s = A[i] + 1;
      ll e = A[i + 1];
      if (e - s > 0 && e - s < m) {
        ok = false;
        break;
      }
      cnt += (e - s + m - 1) / m;
    }
    if (ok) {
      ans = min(ans, cnt);
      l = m;
    } else {
      r = m;
    }
  }
  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task D - Stamp
User nakaken88
Language C++ (GCC 9.2.1)
Score 400
Code Size 852 Byte
Status AC
Exec Time 68 ms
Memory 4772 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:8: warning: unused variable ‘i’ [-Wunused-variable]
   25 |     ll i = 0;
      |        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
handmade_00.txt AC 4 ms 3580 KiB
handmade_01.txt AC 5 ms 3448 KiB
random_00.txt AC 3 ms 3508 KiB
random_01.txt AC 2 ms 3544 KiB
random_02.txt AC 31 ms 4228 KiB
random_03.txt AC 46 ms 4688 KiB
random_04.txt AC 2 ms 3616 KiB
random_05.txt AC 35 ms 4212 KiB
random_06.txt AC 44 ms 4772 KiB
random_07.txt AC 2 ms 3652 KiB
random_08.txt AC 2 ms 3656 KiB
random_09.txt AC 68 ms 4692 KiB
random_10.txt AC 2 ms 3448 KiB
random_11.txt AC 31 ms 4248 KiB
random_12.txt AC 2 ms 3508 KiB
random_13.txt AC 2 ms 3512 KiB
random_14.txt AC 32 ms 4480 KiB
random_15.txt AC 62 ms 4452 KiB
random_16.txt AC 3 ms 3580 KiB
random_17.txt AC 3 ms 3584 KiB
random_18.txt AC 41 ms 4624 KiB
random_19.txt AC 3 ms 3636 KiB
random_20.txt AC 3 ms 3652 KiB
random_21.txt AC 17 ms 3492 KiB
random_22.txt AC 3 ms 3508 KiB
random_23.txt AC 5 ms 3552 KiB
sample_01.txt AC 2 ms 3512 KiB
sample_02.txt AC 3 ms 3452 KiB
sample_03.txt AC 4 ms 3452 KiB
sample_04.txt AC 2 ms 3560 KiB