-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlrquer.cpp
36 lines (35 loc) · 934 Bytes
/
lrquer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
int T;
cin>>T;
for (int i = 0; i < T; i++) {
int N, Q, type, L, R, X, Y;
cin>>N>>Q;
long long int A[N];
for (int j = 0; j < N; j++)
cin>>A[j];
for (int j = 0; j < Q; j++) {
cin>>type;
if (type == 1) {
long long int ans = -1e+5;
cin>>L>>R;
if (L == R) {
cout<<0<<endl;
}
else {
for (int k = L-1; k < R; k++)
if (ans < (A[k]-A[L-1])*(A[R-1]-A[k]))
ans = (A[k]-A[L-1])*(A[R-1]-A[k]);
cout<<ans<<endl;
}
}
else {
cin>>X>>Y;
A[X-1] = Y;
}
}
}
return 0;
}