#include <bits/stdc++.h>
#define ll long long
#define d double
using namespace std;
const int MAXN = 5e5+1;
const ll MOD = 1e9+7;
int x[MAXN], y[MAXN], n;
struct node{
d mx, sum;
ll res, mult;
}tree[MAXN<<2];
void pushup(int p){
tree[p].sum = tree[p<<1].sum+tree[(p<<1)|1].sum;
tree[p].mx = max(tree[p<<1].mx,tree[p<<1].sum+tree[(p<<1)|1].mx);
tree[p].mult = tree[p<<1].mult*tree[(p<<1)|1].mult%MOD;
if(tree[p<<1].mx >= tree[p<<1].sum+tree[(p<<1)|1].mx){
tree[p].res = tree[p<<1].res;
}
else{
tree[p].res = tree[(p<<1)|1].res%MOD*tree[p<<1].mult%MOD;
}
}
void build(int l, int r, int p){
if(l == r){
tree[p].sum = log(1.0*x[l]);
tree[p].mx = log(1.0*x[l]*y[l]);
tree[p].mult = x[l]%MOD;
tree[p].res = x[l]%MOD*y[l]%MOD;
return;
}
int mid = (l+r)>>1;
build(l,mid,(p<<1)); build(mid+1,r,(p<<1)|1);
pushup(p);
}
void upd(int tar, int l, int r, int p){
if(l == r){
tree[p].mx = log(1.0*x[tar]*y[tar]);
tree[p].sum = log(1.0*x[tar]);
tree[p].mult = x[tar]%MOD;
tree[p].res = x[tar]%MOD*y[tar]%MOD;
return;
}
int mid = (l+r)>>1;
if(tar <= mid) upd(tar,l,mid,p<<1);
else upd(tar,mid+1,r,(p<<1)|1);
pushup(p);
}
ll init(int N, int X[], int Y[]){
n = N;
for(int i = 0;i<N;++i){
x[i+1] = X[i];
y[i+1] = Y[i];
}
build(1,N,1);
return tree[1].res;
}
ll updateX(int pos, int val){
x[pos+1] = val;
upd(pos+1,1,n,1);
return tree[1].res;
}
ll updateY(int pos, int val){
y[pos+1] = val;
upd(pos+1,1,n,1);
return tree[1].res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
6 |
Correct |
0 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
0 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
0 ms |
4444 KB |
Output is correct |
16 |
Correct |
0 ms |
4444 KB |
Output is correct |
17 |
Correct |
0 ms |
4440 KB |
Output is correct |
18 |
Correct |
0 ms |
4444 KB |
Output is correct |
19 |
Correct |
0 ms |
4444 KB |
Output is correct |
20 |
Correct |
0 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
6 |
Correct |
0 ms |
4444 KB |
Output is correct |
7 |
Correct |
0 ms |
4444 KB |
Output is correct |
8 |
Correct |
0 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
0 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
0 ms |
4444 KB |
Output is correct |
16 |
Correct |
0 ms |
4444 KB |
Output is correct |
17 |
Correct |
0 ms |
4444 KB |
Output is correct |
18 |
Correct |
0 ms |
4444 KB |
Output is correct |
19 |
Correct |
0 ms |
4444 KB |
Output is correct |
20 |
Correct |
0 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4440 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
42916 KB |
Output is correct |
2 |
Correct |
86 ms |
43092 KB |
Output is correct |
3 |
Correct |
62 ms |
46696 KB |
Output is correct |
4 |
Correct |
73 ms |
50560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
0 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
0 ms |
4444 KB |
Output is correct |
12 |
Correct |
0 ms |
4444 KB |
Output is correct |
13 |
Correct |
0 ms |
4444 KB |
Output is correct |
14 |
Correct |
0 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
0 ms |
4444 KB |
Output is correct |
18 |
Correct |
0 ms |
4548 KB |
Output is correct |
19 |
Correct |
0 ms |
4444 KB |
Output is correct |
20 |
Correct |
0 ms |
4444 KB |
Output is correct |
21 |
Correct |
0 ms |
4444 KB |
Output is correct |
22 |
Correct |
0 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4556 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4552 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4648 KB |
Output is correct |
31 |
Correct |
1 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
35 ms |
46100 KB |
Output is correct |
34 |
Correct |
33 ms |
45968 KB |
Output is correct |
35 |
Correct |
49 ms |
53100 KB |
Output is correct |
36 |
Correct |
47 ms |
52840 KB |
Output is correct |
37 |
Correct |
20 ms |
44376 KB |
Output is correct |
38 |
Correct |
26 ms |
45188 KB |
Output is correct |
39 |
Correct |
18 ms |
44124 KB |
Output is correct |
40 |
Correct |
34 ms |
48044 KB |
Output is correct |
41 |
Correct |
17 ms |
44120 KB |
Output is correct |
42 |
Correct |
18 ms |
44184 KB |
Output is correct |
43 |
Correct |
32 ms |
48468 KB |
Output is correct |
44 |
Correct |
33 ms |
48468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4440 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
6 |
Correct |
0 ms |
4444 KB |
Output is correct |
7 |
Correct |
0 ms |
4444 KB |
Output is correct |
8 |
Correct |
0 ms |
4444 KB |
Output is correct |
9 |
Correct |
0 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
0 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
0 ms |
4444 KB |
Output is correct |
15 |
Correct |
0 ms |
4444 KB |
Output is correct |
16 |
Correct |
0 ms |
4444 KB |
Output is correct |
17 |
Correct |
0 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4440 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
0 ms |
4444 KB |
Output is correct |
21 |
Correct |
0 ms |
4444 KB |
Output is correct |
22 |
Correct |
0 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4440 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
46 ms |
46888 KB |
Output is correct |
34 |
Correct |
88 ms |
55900 KB |
Output is correct |
35 |
Correct |
64 ms |
46928 KB |
Output is correct |
36 |
Correct |
73 ms |
50684 KB |
Output is correct |
37 |
Correct |
32 ms |
46164 KB |
Output is correct |
38 |
Correct |
33 ms |
46164 KB |
Output is correct |
39 |
Correct |
49 ms |
52888 KB |
Output is correct |
40 |
Correct |
47 ms |
53036 KB |
Output is correct |
41 |
Correct |
19 ms |
44380 KB |
Output is correct |
42 |
Correct |
26 ms |
45140 KB |
Output is correct |
43 |
Correct |
18 ms |
44116 KB |
Output is correct |
44 |
Correct |
33 ms |
47960 KB |
Output is correct |
45 |
Correct |
18 ms |
44380 KB |
Output is correct |
46 |
Correct |
18 ms |
44236 KB |
Output is correct |
47 |
Correct |
32 ms |
48352 KB |
Output is correct |
48 |
Correct |
32 ms |
48464 KB |
Output is correct |
49 |
Correct |
69 ms |
48008 KB |
Output is correct |
50 |
Correct |
71 ms |
47956 KB |
Output is correct |
51 |
Correct |
72 ms |
54816 KB |
Output is correct |
52 |
Correct |
67 ms |
54608 KB |
Output is correct |
53 |
Correct |
56 ms |
46420 KB |
Output is correct |
54 |
Correct |
49 ms |
47004 KB |
Output is correct |
55 |
Correct |
36 ms |
45140 KB |
Output is correct |
56 |
Correct |
55 ms |
49752 KB |
Output is correct |
57 |
Correct |
36 ms |
45880 KB |
Output is correct |
58 |
Correct |
40 ms |
46416 KB |
Output is correct |
59 |
Correct |
32 ms |
48504 KB |
Output is correct |