#include <bits/stdc++.h>
#define fr(i, l, r) for(ll i = l; i <= r; ++ i)
#define rf(i, r, l) for(ll i = l; i >= r; -- i)
using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
#define INF 87654321
#define IINF 1987654321987654321
#define MOD 1000000007
const ll N = (ll)1e6 + 10;
ll n, Q;
ll a[N];
int main() {
cin >> n >> Q;
fr(i, 1, n)cin >> a[i];
a[0] = a[1];
fr(z, 1, Q){
ll t;
cin >> t;
if(t == 1){
ll p, v;
cin >> p >> v;
if(p == 1){
a[0] = v;
}
a[p] = v;
} else{
ll x, ans = 0;
cin >> x;
fr(i, 1, n){
bool ok = 0;
if(a[i - 1] <= x && x <= a[i] || a[i] <= x && x <= a[i - 1])ok = 1;
if(ok){
//cout << " " << i << ' ' << a[i - 1] << ' ' << a[i] << endl;
ans ++;
}
}
cout << ans << "\n";
}
}
}
/*
4 0
4
1 2
3 4
2 3
1 4
*/
Compilation message
game.cpp: In function 'int main()':
game.cpp:41:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(a[i - 1] <= x && x <= a[i] || a[i] <= x && x <= a[i - 1])ok = 1;
~~~~~~~~~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
376 KB |
Output is correct |
6 |
Correct |
7 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
376 KB |
Output is correct |
6 |
Correct |
7 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
8 |
Execution timed out |
1061 ms |
1812 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
376 KB |
Output is correct |
6 |
Correct |
7 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
8 |
Execution timed out |
1061 ms |
1812 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |