#include<iostream>
#include<math.h>
#include"horses.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7;
const int TREE_SIZE=1<<19;
int n;
int x[500000];
ld xlog[500000];
int y[500000];
ld ylog[500000];
ll powm(ll base,ll exp){
base%=MOD;
exp%=MOD-1;
ll res=1;
for(int i=0;i<32;i++){
if(exp&(1<<i))
res=res*base%MOD;
base=base*base%MOD;
}
return res;
}
ld tree1[2*TREE_SIZE];
ld lazy1[2*TREE_SIZE];
// push lazy
void update1(int node){
if(lazy1[node]!=0){
tree1[node]+=lazy1[node];
if(node<TREE_SIZE){
lazy1[2*node]+=lazy1[node];
lazy1[2*node+1]+=lazy1[node];
}
lazy1[node]=0;
}
}
void add1(int node,int l,int r,int rl,int rr,ld c){
if(l<=rl&&rr<=r){
lazy1[node]+=c;
update1(node);
return;
}
update1(node);
if(rr<=l||r<=rl)
return;
int mid=(rl+rr)/2;
add1(2*node,l,r,rl,mid,c);
add1(2*node+1,l,r,mid,rr,c);
tree1[node]=max(tree1[2*node],tree1[2*node+1]);
}
int get1(int node,int rl,int rr){
if(rl==rr-1)
return rl;
int mid=(rl+rr)/2;
if(tree1[2*node]>=tree1[2*node+1])
return get1(2*node,rl,mid);
else
return get1(2*node+1,mid,rr);
}
int get_maxi(){
return get1(1,0,TREE_SIZE);
}
int get_prod(int maxi){
ll res=1;
for(int i=0;i<=maxi;i++){
res*=x[i];
res%=MOD;
}
return int(res*y[maxi]%MOD);
}
void setx(int pos,int val){
x[pos]=val;
ld new_val=log(x[pos]);
add1(1,pos,n,0,TREE_SIZE,new_val-xlog[pos]);
xlog[pos]=new_val;
}
void sety(int pos,int val){
y[pos]=val;
ld new_val=log(y[pos]);
add1(1,pos,pos+1,0,TREE_SIZE,new_val-ylog[pos]);
ylog[pos]=new_val;
}
// -------------------------------
int init(int N,int X[],int Y[]){
n=N;
for(int i=0;i<n;i++){
setx(i,X[i]);
sety(i,Y[i]);
}
return get_prod(get_maxi());
}
int updateX(int pos,int val){
setx(pos,val);
return get_prod(get_maxi());
}
int updateY(int pos,int val){
sety(pos,val);
return get_prod(get_maxi());
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10584 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6648 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
8536 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
13 |
Correct |
1 ms |
6744 KB |
Output is correct |
14 |
Correct |
1 ms |
10584 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
2 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8536 KB |
Output is correct |
12 |
Correct |
1 ms |
10840 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
10588 KB |
Output is correct |
15 |
Correct |
1 ms |
8536 KB |
Output is correct |
16 |
Correct |
1 ms |
8792 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
1 ms |
6492 KB |
Output is correct |
23 |
Correct |
7 ms |
4700 KB |
Output is correct |
24 |
Correct |
8 ms |
8796 KB |
Output is correct |
25 |
Correct |
7 ms |
4696 KB |
Output is correct |
26 |
Correct |
7 ms |
4696 KB |
Output is correct |
27 |
Correct |
7 ms |
8792 KB |
Output is correct |
28 |
Correct |
8 ms |
10844 KB |
Output is correct |
29 |
Correct |
6 ms |
8644 KB |
Output is correct |
30 |
Correct |
7 ms |
4700 KB |
Output is correct |
31 |
Correct |
4 ms |
8796 KB |
Output is correct |
32 |
Correct |
5 ms |
8792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1536 ms |
55136 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
10588 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
1 ms |
6492 KB |
Output is correct |
23 |
Correct |
7 ms |
4800 KB |
Output is correct |
24 |
Correct |
8 ms |
8648 KB |
Output is correct |
25 |
Correct |
9 ms |
4956 KB |
Output is correct |
26 |
Correct |
7 ms |
4696 KB |
Output is correct |
27 |
Correct |
7 ms |
8796 KB |
Output is correct |
28 |
Correct |
8 ms |
10852 KB |
Output is correct |
29 |
Correct |
6 ms |
8644 KB |
Output is correct |
30 |
Correct |
7 ms |
4700 KB |
Output is correct |
31 |
Correct |
4 ms |
8796 KB |
Output is correct |
32 |
Correct |
5 ms |
8796 KB |
Output is correct |
33 |
Execution timed out |
1537 ms |
59580 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
10584 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6744 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
10588 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
10584 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8632 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
1 ms |
6492 KB |
Output is correct |
22 |
Correct |
1 ms |
6492 KB |
Output is correct |
23 |
Correct |
7 ms |
4700 KB |
Output is correct |
24 |
Correct |
8 ms |
8796 KB |
Output is correct |
25 |
Correct |
7 ms |
4700 KB |
Output is correct |
26 |
Correct |
7 ms |
4816 KB |
Output is correct |
27 |
Correct |
7 ms |
8796 KB |
Output is correct |
28 |
Correct |
8 ms |
10832 KB |
Output is correct |
29 |
Correct |
6 ms |
8796 KB |
Output is correct |
30 |
Correct |
8 ms |
4956 KB |
Output is correct |
31 |
Correct |
4 ms |
8796 KB |
Output is correct |
32 |
Correct |
6 ms |
8836 KB |
Output is correct |
33 |
Execution timed out |
1573 ms |
57268 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |