Submission #70282136


Source Code Expand

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
struct S {
	int x;
	int y;
};
S op(S c1, S c2) { return {c1.x + c2.x, c1.y + c2.y}; }
S e() { return {0, 0}; }
using F = int;
S mapping(F f, S c) {
	if (f == 0)
		c.x = 0;
	if (f == 1)
		c.x = c.y;
	return c;
}
F composition(F f, F g) { return f == -1 ? g : f; }
F id() { return -1; }
int x;
bool ga(S c) { return c.x <= x; }
int y;
bool gb(S c) { return c.x > y; }
int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> w(n);
	for (int &i : w) cin >> i;
	vector<int> a(n);
	rep(i, n - 1) a[i + 1] = w[n - i - 1] - w[n - i - 2];
	vector<S> to_sega(n), to_segb(n);
	rep(i, n) {
		to_sega[i] = {0, a[i]};
		to_segb[i] = {-a[i], -a[i]};
	}
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg_a(to_sega), seg_b(to_segb);
	int que;
	cin >> que;
	while (que--) {
		int ty;
		cin >> ty;
		if (ty == 1) {
			int v;
			cin >> v;
			v = n - v + 1;
			seg_a.apply(v, n, 0);
			seg_b.apply(v, n, 1);
			continue;
		}
		if (ty == 2) {
			int v;
			cin >> v;
			v = n - v + 1;
			seg_a.apply(v, n, 1);
			seg_b.apply(v, n, 0);
			continue;
		}
		cin >> x;
		y = x - w[n - 1];
		if (y >= 0) {
			cout << 0 << endl;
			continue;
		}
		cout << min(seg_a.max_right<ga>(0), seg_b.max_right<gb>(0)) << endl;
	}
}

Submission Info

Submission Time
Task F - Pyramid Alignment
User sounansya
Language C++ 20 (gcc 12.2)
Score 525
Code Size 1430 Byte
Status AC
Exec Time 348 ms
Memory 18176 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 525 / 525
Status
AC × 1
AC × 16
Set Name Test Cases
Sample 00-sample-01.txt
All 00-sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, max-01.txt, max-02.txt, max-03.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 3 ms 3348 KiB
01-01.txt AC 191 ms 17560 KiB
01-02.txt AC 162 ms 17012 KiB
01-03.txt AC 192 ms 11244 KiB
01-04.txt AC 243 ms 18116 KiB
01-05.txt AC 245 ms 18176 KiB
01-06.txt AC 269 ms 18068 KiB
01-07.txt AC 245 ms 18088 KiB
01-08.txt AC 204 ms 17856 KiB
01-09.txt AC 212 ms 17896 KiB
01-10.txt AC 212 ms 17344 KiB
01-11.txt AC 219 ms 17856 KiB
01-12.txt AC 230 ms 17320 KiB
max-01.txt AC 348 ms 18112 KiB
max-02.txt AC 155 ms 18176 KiB
max-03.txt AC 129 ms 18112 KiB