Submission #894503

# Submission time Handle Problem Language Result Execution time Memory
894503 2023-12-28T11:18:52 Z vjudge1 The short shank; Redemption (BOI21_prison) C++17
0 / 100
32 ms 54916 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5;

int n, d, t, a[N], b[N];
vector<int> add[N], rem[N];

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> d >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > t) continue;
    
    add[i].push_back(i);
    rem[min(n, i + t-a[i] + 1)].push_back(i);
  }
  
  int ans = 0;
  set<int> st;
  for (int i = 0; i < n; i++) {
    for (int& j : add[i]) st.insert(j);
    for (int& j : rem[i]) st.erase(j);

    if (a[i] <= t) {
      b[i] = -1;
      continue;
    }

    if (st.empty()) {
      b[i] = -1;
      ans++;
    }
    else b[i] = *prev(st.end());
  }

  int mx = 0;
  st.clear();
  for (int i = n-1; i >= 0; i--) {
    while (!st.empty() && *prev(st.end()) > i) {
      st.erase(st.end());
    }

    int sz = st.size();
    mx = max(mx, sz);

    if (b[i] != -1) st.insert(b[i]);
  }

  cout << n - ans - mx << "\n";
}
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 54868 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 54876 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 54868 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 54916 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 54868 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 54868 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -