/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 488.0 KiB
#3 Accepted 621ms 2.812 MiB
#4 Accepted 609ms 5.793 MiB
#5 Accepted 427ms 4.629 MiB
#6 Wrong Answer 387ms 2.211 MiB
#7 Accepted 2ms 540.0 KiB
#8 Accepted 2ms 328.0 KiB
#9 Accepted 690ms 5.742 MiB
#10 Accepted 706ms 6.887 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(n == 1) continue;
            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:19:52
Judged At
2024-10-03 13:22:29
Judged By
Score
90
Total Time
706ms
Peak Memory
6.887 MiB