답안 #793637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793637 2023-07-26T04:58:24 Z GEN 이지후(#10094) Triangle Collection (CCO23_day2problem3) C++17
10 / 25
4000 ms 1132 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = array<int, 2>;
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	lint moksum = 0, oddcnt = 0;
	for (auto &x : a)
		cin >> x, moksum += x / 2, oddcnt += x % 2;
	auto solve = [&]() {
		lint deficiency = 0;
		lint runsum = 0;
		int ptr = n - 1;
		for (int x = n; x >= 1; x--) {
			runsum += a[x - 1] % 2;
			while (ptr >= x / 2) {
				runsum -= a[ptr--] / 2;
			}
			deficiency = max(deficiency, runsum);
		}
		lint matching = oddcnt - deficiency;
		return matching + (2 * moksum - 2 * matching) / 3;
	};
	while (q--) {
		int i, d;
		cin >> i >> d;
		moksum -= a[i - 1] / 2;
		oddcnt -= a[i - 1] % 2;
		a[i - 1] += d;
		moksum += a[i - 1] / 2;
		oddcnt += a[i - 1] % 2;
		cout << solve() << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 11 ms 212 KB Output is correct
7 Correct 11 ms 336 KB Output is correct
8 Correct 5 ms 324 KB Output is correct
9 Correct 10 ms 332 KB Output is correct
10 Correct 10 ms 336 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 332 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 5 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 11 ms 212 KB Output is correct
7 Correct 11 ms 336 KB Output is correct
8 Correct 5 ms 324 KB Output is correct
9 Correct 10 ms 332 KB Output is correct
10 Correct 10 ms 336 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 332 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 5 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 10 ms 340 KB Output is correct
18 Correct 10 ms 352 KB Output is correct
19 Correct 12 ms 340 KB Output is correct
20 Correct 12 ms 348 KB Output is correct
21 Correct 11 ms 332 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 10 ms 340 KB Output is correct
24 Correct 10 ms 340 KB Output is correct
25 Correct 10 ms 356 KB Output is correct
26 Correct 10 ms 212 KB Output is correct
27 Correct 10 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 336 KB Output is correct
2 Correct 10 ms 288 KB Output is correct
3 Correct 35 ms 584 KB Output is correct
4 Execution timed out 4067 ms 1132 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 212 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 12 ms 340 KB Output is correct
4 Correct 10 ms 328 KB Output is correct
5 Execution timed out 4077 ms 1116 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 11 ms 212 KB Output is correct
7 Correct 11 ms 336 KB Output is correct
8 Correct 5 ms 324 KB Output is correct
9 Correct 10 ms 332 KB Output is correct
10 Correct 10 ms 336 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 332 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 5 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 10 ms 340 KB Output is correct
18 Correct 10 ms 352 KB Output is correct
19 Correct 12 ms 340 KB Output is correct
20 Correct 12 ms 348 KB Output is correct
21 Correct 11 ms 332 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 10 ms 340 KB Output is correct
24 Correct 10 ms 340 KB Output is correct
25 Correct 10 ms 356 KB Output is correct
26 Correct 10 ms 212 KB Output is correct
27 Correct 10 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 10 ms 336 KB Output is correct
30 Correct 10 ms 288 KB Output is correct
31 Correct 35 ms 584 KB Output is correct
32 Execution timed out 4067 ms 1132 KB Time limit exceeded
33 Halted 0 ms 0 KB -