Submission #1106365

# Submission time Handle Problem Language Result Execution time Memory
1106365 2024-10-30T05:06:15 Z stdfloat Simple game (IZhO17_game) C++17
22 / 100
1000 ms 1104 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

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

	int n, q;
	cin >> n >> q;

	vector<int> a(n);
	for (auto &i : a)
		cin >> i;

	while (q--) {
		int tp, x;
		cin >> tp >> x;

		if (tp == 1) {
			int vl;
			cin >> vl;

			a[--x] = vl;
		}
		else {
			int cnt = 0;
			vector<bool> vis(n);
			for (int i = 0; i + 1 < n; i++) {
				int mn = min(a[i], a[i + 1]), mx = max(a[i], a[i + 1]);
				if (mn <= x && x <= mx) {
					cnt++;
					if (mx == a[i] && mx == x && vis[i]) cnt--;
					if (mx == a[i + 1] && mx == x) vis[i + 1] = true;
				}
			}

			cout << cnt << '\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Execution timed out 1045 ms 1104 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Execution timed out 1045 ms 1104 KB Time limit exceeded
9 Halted 0 ms 0 KB -