# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1268844 | kawhiet | Simple game (IZhO17_game) | C++20 | 2 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
void fileio(string s) {
#ifndef LOCAL
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
#endif
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
fileio("game");
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
while (q--) {
int t;
cin >> t;
if (t == 1) {
int id, h;
cin >> id >> h;
id--;
a[id] = h;
}
else {
int x;
cin >> x;
int res = 0;
for (int i = 1; i < n; i++) {
if (min(a[i], a[i - 1]) <= x && x <= max(a[i], a[i - 1])) {
res++;
}
}
cout << res << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |