#include "bits/stdc++.h"
using namespace std;
using ll = long long;
/*void dfs(int u){
vis[u]=true;
cout<<u<<" ";
for(int v:g[u]){
if(vis[v])continue;
dfs(v);
}
}*/
void solve(){
int n,q;cin>>n>>q;
/*g.assign(n+1,{});
vis.assign(n+1,false);
*/
vector<int>vec(n+1);
for(int i=1;i<=n;i++){
cin>>vec[i];
}
vector<pair<int,int>>g;
for(int i=1;i<=n;i++){
if(i+1>n)break;
g.emplace_back(make_pair(min(vec[i],vec[i+1]),max(vec[i],vec[i+1])));
//cout<<vec[i]<<" "<<vec[i+1]<<endl;
}
//for(auto [x,y]:g)cout<<x<<" "<<y<<endl;
while(q--){
int r;cin>>r;
if(r==1){
int a,b;cin>>a>>b;
}
else{
int cnt=0;
int c;cin>>c;
for(auto [x,y]:g){
if(x<c&&c<y){
cnt++;
}
}
cout<<cnt<<endl;
}
}
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef prince
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |