This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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;
~~~~~~~~~~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |