Submission #1029285

#TimeUsernameProblemLanguageResultExecution timeMemory
1029285MDarioThe short shank; Redemption (BOI21_prison)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <vector>
using namespace std;

#define F first
#define S second
typedef long long ll;

const string noyes[2] = {"NO", "YES"};
const ll INFLL = (1ll << 62);
const int INF = (1 << 30);
const int MAXN = 300'000;
const ll MOD = 1'000'000'007;

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

  ll n, D, T;
  cin >> n >> D >> T;

  ll a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  ll pref[n];
  {
    ll c = 0;
    ll last = INF;
    for (int i = 0; i < n; i++) {
      last = min(last + 1, a[i]);
      if (last <= T) {
        c++;
      }
      pref[i] = c;
      // cout << c << " ";
    }
    // cout << "\n";
  }

  ll suf[n];
  {
    stack<ll> slow;
    ll c = 0;
    ll last = INF;
    for (int i = n - 1; i >= 0; i--) {
      last = a[i];
      slow.push(i);
      while (!slow.empty() && abs(i - slow.top()) + last <= T) {
        c++;
        slow.pop();
      }
      suf[i] = c;
    }
    // for (int i = 0; i < n; i++)
    //   cout << suf[i] << " ";
    // cout << "\n";
  }

  ll ans = n;
  for (int i = 0; i + 1 < n; i++)
    ans = min(ans, pref[i] + suf[i + 1]);
  cout << ans << "\n";

  return 0;
}

Compilation message (stderr)

prison.cpp:12:21: warning: missing terminating ' character
   12 | const int MAXN = 300'000;
      |                     ^
prison.cpp:12:21: error: missing terminating ' character
   12 | const int MAXN = 300'000;
      |                     ^~~~~
prison.cpp:13:17: warning: multi-character character constant [-Wmultichar]
   13 | const ll MOD = 1'000'000'007;
      |                 ^~~~~
prison.cpp:13:25: warning: missing terminating ' character
   13 | const ll MOD = 1'000'000'007;
      |                         ^
prison.cpp:13:25: error: missing terminating ' character
   13 | const ll MOD = 1'000'000'007;
      |                         ^~~~~
prison.cpp:13:1: error: expected ',' or ';' before 'const'
   13 | const ll MOD = 1'000'000'007;
      | ^~~~~