/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 532.0 KiB
#3 Accepted 570ms 2.773 MiB
#4 Accepted 471ms 5.504 MiB
#5 Accepted 379ms 4.629 MiB
#6 Wrong Answer 352ms 2.215 MiB
#7 Accepted 1ms 344.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Accepted 684ms 5.629 MiB
#10 Accepted 582ms 6.789 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{
            a[l] = r;
            if(n == 1) continue;
            if(l){
                s.erase(l);
               // a[l] = r;
                if(a[l] < a[l - 1]) s.insert(l);
            }
            if(l < n - 1){
                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:21:27
Judged At
2024-11-11 03:11:51
Judged By
Score
90
Total Time
684ms
Peak Memory
6.789 MiB