제출 #570508

#제출 시각아이디문제언어결과실행 시간메모리
570508cheissmartThe short shank; Redemption (BOI21_prison)C++14
0 / 100
127 ms100156 KiB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
	cerr << to_string(h);
	if(sizeof ...(t)) cerr << ", ";
	DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7, N = 2e6 + 7;

int a[N], p[N], down[N];
vi G[N];

void dfs(int u) {
	down[u] = 1;
	for(int v:G[u]) {
		dfs(v);
		down[u] = max(down[u], down[v] + 1);
	}
}

vi hebe[N];

signed main()
{
	IO_OP;

	int n, d, t;
	cin >> n >> d >> t;
	int ans = n;

	V<pi> stk, aux;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] <= t) {
			int r = i + t - a[i];
			while(SZ(stk) && stk.back().S <= r) stk.pop_back();
			stk.EB(i, r);
		} else {
			while(SZ(stk) && stk.back().S < i) stk.pop_back();
			if(SZ(stk)) {
				// [stk.back().F, i)
				// aux.EB(i, (i + 1));
				// aux.EB(stk.back().F, -(i + 1));
				aux.EB(i, -1);
				aux.EB(stk.back().F, 1);
			}
		}
	}
	sort(ALL(aux), less<>());
	int mx = 0, cnt = 0;
	for(auto[pos, val]:aux) {
		if(val > 0) cnt++;
		else cnt--;
		mx = max(mx, cnt);
	}

	cout << ans - mx << '\n';

	// vi nodes;

	// int lst = 0, tp = 1;
	// for(auto[pos, op]:aux) {
	// 	int u = abs(op);
	// 	if(op > 0) {
	// 		assert(pos != lst_pos);
	// 		if(tp == 1) p[u] = lst;
	// 		else p[u] = p[lst];
	// 		nodes.PB(u);
	// 	}
	// 	lst = u, tp = op > 0;
	// }

	// for(int u:nodes) if(p[u]) {
	// 	G[p[u]].PB(u);
	// }
	// for(int u:nodes) if(!p[u]) {
	// 	dfs(u);
	// 	hebe[down[u]].PB(u);
	// }

	// function<void(int)> go = [&] (int u) {
	// 	int nxt = -1;
	// 	for(int v:G[u]) if(down[v] + 1 == down[u]) nxt = v;
	// 	for(int v:G[u]) if(v != nxt) hebe[down[v]].PB(v);
	// 	if(nxt != -1)
	// 		go(nxt);
	// };

	// for(int i = n; i >= 1 && d; i--) {
	// 	while(d && SZ(hebe[i])) {
	// 		int u = hebe[i].back();
	// 		hebe[i].pop_back();
	// 		go(u);
	// 		assert(down[u] == i);
	// 		ans -= i;
	// 		d--;
	// 	}
	// }
	// cout << ans << '\n';

}

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

prison.cpp: In function 'int main()':
prison.cpp:74:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   74 |  for(auto[pos, val]:aux) {
      |          ^
#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...