제출 #828901

#제출 시각아이디문제언어결과실행 시간메모리
828901QwertyPiThe short shank; Redemption (BOI21_prison)C++14
10 / 100
116 ms62992 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") using namespace std; const int N = 2e6 + 11; const int MAXN = 2e6 + 11; int a[N]; vector<int> rm[N]; struct range{ int l, r; }; struct BIT{ int bit[MAXN]; void add(int p, int v){ p++; for(int i = p; i < MAXN; i += i & -i) bit[i] += v; } int qry(int p){ p++; int r = 0; for(int i = p; i; i -= i & -i) r += bit[i]; return r; } } bit; int32_t main(){ cin.tie(0); cout.tie(0)->sync_with_stdio(false); int n, d, t; cin >> n >> d >> t; for(int i = 0; i < n; i++){ cin >> a[i]; a[i] = max(0, t - a[i] + 1); } for(int i = 0; i < n; i++){ if(a[i] == 0) a[i] = -1; else a[i] = min(n, i + a[i]), rm[a[i]].push_back(i); } priority_queue<int> pq1, pq2; vector<range> R; int ans = 0; for(int i = 0; i < n; i++){ for(auto j : rm[i]) pq2.push(j); while(pq1.size() && pq2.size() && pq1.top() == pq2.top()) pq1.pop(), pq2.pop(); if(a[i] == -1){ if(!pq1.empty()) R.push_back({pq1.top(), i - 1}), ans++; }else{ pq1.push(i); ans++; } } for(auto [l, r] : R){ bit.add(l, 1); bit.add(r + 1, -1); } int mx = -1; for(int i = 0; i < n; i++){ mx = max(mx, bit.qry(i)); } cout << ans - mx << endl; }

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'int32_t main()':
prison.cpp:47:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |  for(auto [l, r] : R){
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...