Submission #1316348

#TimeUsernameProblemLanguageResultExecution timeMemory
1316348aaaaaaaaSimple game (IZhO17_game)C++20
22 / 100
1095 ms848 KiB
#include <bits/stdc++.h>
using namespace std;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    while(q--){
        int t, l, r;
        cin >> t;
        if(t == 2){
            cin >> l;
            int ans = 0;
            for(int j = 1; j <= n - 1; ++j){
                if((a[j] >= l && a[j + 1] <= l) || (a[j] <= l && a[j + 1] >= l)) ans += 1;
            }
            cout << ans << "\n";
        }else{
            cin >> l >> r;
            a[l] = r;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...