Submission #590518

#TimeUsernameProblemLanguageResultExecution timeMemory
590518zeroesandonesSimple game (IZhO17_game)C++17
22 / 100
1087 ms1620 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i) #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb push_back void print(vi &a) { for(auto i : a) cout << i << " "; cout << nl; } void solve() { int n, m; cin >> n >> m; vi a(n + 1); FOR(i, 1, n + 1) cin >> a[i]; FOR(i, 0, m) { int x; cin >> x; if(x == 1) { int p, h; cin >> p >> h; a[p] = h; } else { int h; cin >> h; ll cnt = 0; FOR(j, 2, n + 1) { if((a[j - 1] < h && h < a[j]) || (a[j - 1] > h && h > a[j])) ++cnt; } cout << cnt << nl; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...