Pagini recente » Borderou de evaluare (job #2113845) | Borderou de evaluare (job #149765) | Borderou de evaluare (job #733496) | Borderou de evaluare (job #1581797) | Cod sursa (job #1414222)
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define sc second
#define pob pop_back
#define pub push_back
#define eps 1E-7
#define sz(a) a.size()
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define fastIO ios_base::sync_with_stdio(false)
#define PI (acos(-1.0))
#define linf (1LL<<62)//>4e18
#define inf (0x7f7f7f7f)//>2e9
const int MAXN = 100010;
#define nds ((nod << 1))
#define ndr ((nod << 1) + 1)
#define max(a, b) ((a) > (b) ? (a) : (b))
int n, m, val, st, dr, pos, maxx;
int arb[4*MAXN + 100];
void query(int nod, int l, int r) {
if(st <= l && r <= dr) {
if(maxx < arb[nod])
maxx = arb[nod];
return;
}
int mid = (l + r) >> 1;
if(st <= mid)
query(nds, l, mid);
if(mid < dr)
query(ndr, mid + 1, r);
}
void update(int nod, int l, int r) {
if(l == r) {
arb[nod] = val;
return;
}
int mid = (l + r) >> 1;
if(mid >= pos)
update(nds, l, mid);
else
update(ndr, mid + 1, r);
arb[nod] = max(arb[nds], arb[ndr]);
}
void read() {
#ifndef ONLINE_JUDGE
assert(freopen("arbint.in", "r", stdin));
assert(freopen("arbint.out", "w", stdout));
#endif
int tip;
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
cin >> val;
pos = i;
update(1, 1, n);
}
while(m--) {
cin >> tip;
if(tip == 0) {
maxx = -1;
cin >> st >> dr;
query(1, 1, n);
cout << maxx << "\n";
}
if(tip == 1) {
cin >> pos >> val;
update(1, 1, n);
}
}
}
int main() {
read();
return 0;
}