/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 541ms 2.723 MiB
#4 Accepted 445ms 5.535 MiB
#5 Accepted 372ms 4.551 MiB
#6 Wrong Answer 336ms 2.32 MiB
#7 Accepted 2ms 320.0 KiB
#8 Accepted 2ms 532.0 KiB
#9 Accepted 682ms 5.75 MiB
#10 Accepted 599ms 6.871 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long

void sol(){
    int n;
    cin >> n;
    int a[n];
    for(int &i:a) cin >> i;
    set<int>s;
    for(int i = 0; i < n; i++){
        if(i and a[i] < a[i - 1]) s.insert(i);
    }
    int q;
    cin >> q;
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
        l--, r--;
        if(t == 2){
            auto it = s.lower_bound(l + 1);
            if(it == s.end()) cout << "YES" << endl;
            else if(*it > r) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
        else{
            if(l){
                if(s.find(l) != s.end()) s.erase(l);
                a[l] = r;
                if(a[l] < a[l - 1]) s.insert(l);
            }
            if(l < n - 1){
                if(s.find(l + 1) != s.end()) s.erase(l + 1);
                a[l] = r;
                if(a[l + 1] < a[l]) s.insert(l + 1);
            }
        }
    }
}
signed main(){
    int t = 1;
    //cin >> t;
    while(t--){
        sol();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 17:18:33
Judged At
2024-11-11 03:12:06
Judged By
Score
90
Total Time
682ms
Peak Memory
6.871 MiB