//#ifndef LOCAL
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#endif
#include <bits/stdc++.h>
using namespace std;
using vecp = vector<pair<int,int>>;
#define vecm(a,n,m) vector<vector<int>>a(n,vector<int>(m,0));
#define int int64_t
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mpii map<int,int>
#define lb lower_bound
#define ub upper_bound
#define foor(i,a,b) for(int i=a;i<b; i++)
#define foor(i,a) foor(i,0,a)
#define ins insert
#define ss second
#define ff first
#define until(x, a) for (auto x : a)
#define ln(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define seea(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
const int mod = 1E9+7;
void solution(){
int n,m;
cin >> n >> m;
int a[n+1];
for(int i=1; i<=n; i++){
cin >> a[i];
}
vector<int> vec(1000005,0);
for(int i=2; i<=n; i++){
int l,r;
l=min(a[i],a[i-1]);
r=max(a[i],a[i-1]);
vec[l]++;
vec[r+1]--;
}
int sum=0;
for(int i=1; i<vec.size(); i++){
sum+=vec[i];
vec[i]=sum;
}
while(m--){
int t,x;
cin >> t >> x;
assert(t == 2);
cout << vec[x] << endl;
}
}
int32_t main(){
clock_t tStart = clock();
std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int q = 1; // cin >> q;
while(q--) {
solution();
// cout << '\n';
}
// cerr<<fixed<<setprecision(3)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
}
Compilation message
game.cpp:19: warning: "foor" redefined
19 | #define foor(i,a) foor(i,0,a)
|
game.cpp:18: note: this is the location of the previous definition
18 | #define foor(i,a,b) for(int i=a;i<b; i++)
|
game.cpp: In function 'void solution()':
game.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i=1; i<vec.size(); i++){
| ~^~~~~~~~~~~
game.cpp: In function 'int32_t main()':
game.cpp:57:13: warning: unused variable 'tStart' [-Wunused-variable]
57 | clock_t tStart = clock();
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
16316 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
16316 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
16316 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |