#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);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
895 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
895 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
895 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |