이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define MAXN 100010
using namespace std;
std::vector<int> v;
multiset<int> ms;
int main(){
    int n,m; cin >> n >> m;
    v.pb(0);
    for(int i=1;i<=n;i++){
        int a; cin >> a;
        v.pb(a);
        //cout << "v[" << i << "]= "<< v[i] << endl;
        if(v[i-1] < a){
            for(int j = v[i-1];j<a;j++){
                ms.insert(j);
            } 
        }
        else{
           for(int j = a;j>=v[i-1];j--){
                ms.insert(j);
            } 
        }
        
        
    }
    bool is1gone = false;
    for(int i=0;i<m;i++){
        int a; cin >> a;
        //cout << "a: " << a << endl;
        if(a == 1){
            int b,c; cin >> b >> c;
            v[b] = c;
            is1gone = true;
        }
        if(a == 2){
            int b; cin >> b;
            int resp = 0;
            if(is1gone == false) resp = ms.count(b)+1;
            else{
                for(int j=2;j<=n;j++){
                    if(v[j] >= b && v[j-1] <= b) resp++;
                    if(v[j-1] >= b && v[j] <= b) resp++;
                }
            }
            printf("%d\n",resp);
        }
    }
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |