#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N], b[N];
int n,m;
void precalc(){
for(int i=0; i<n-1; i++){
for(int j = min(a[i], a[i+1]); j <= max(a[i], a[i+1]); j++){
b[j]++;
}
}
}
int main() {
cin>>n>>m;
int mx=-1;
for(int i=0; i<n; i++){cin>>a[i]; mx=max(mx, a[i]);}
precalc();
// for(int i=1; i<=mx; i++)cout<<b[i]<<" ";
// cout<<endl;
for(int i=0; i<m; i++){
int q;
cin>>q;
if(q==2){
int h;
cin>>h;
cout<<b[h]<<"\n";
}else{
int a,b;
cin>>a>>b;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |