#include "horses.h"
int N;
long long ans,sb3;
long long x[500002],y[500002];
#define MOD 1000000007
long long inv(long long value){
if(value == 1) return 1;
long long tmp = (inv(MOD%value)*((-MOD)/value));
tmp %= MOD;
if(tmp < 0) tmp += MOD;
return tmp;
}
int process1(){
int i,t;
long long tmp;
ans = x[1];
t = tmp = 1;
for(i=2; i<=N; i++){
tmp *= x[i];
if(tmp > y[t] || tmp*y[i] > y[t]){
t = i;
ans *= (tmp%MOD); ans %= MOD;
tmp = 1;
}
}
sb3 = 1;
for(i=1; i<=N-30; i++){
sb3 *= x[i];
sb3 %= MOD;
}
ans *= y[t];
ans %= MOD;
return (int)ans;
}
void subtask3(){
int i,t;
long long tmp;
ans = x[N-29]*sb3; ans %= MOD;
t = N-29; tmp = 1;
for(i=N-28; i<=N; i++){
tmp *= x[i];
if(tmp > y[t] || tmp*y[i] > y[t]){
t = i;
ans *= (tmp%MOD); ans %= MOD;
tmp = 1;
}
}
ans *= y[t];
ans %= MOD;
}
int init(int n, int X[], int Y[]) {
int i;
for(i=1; i<=n; i++){
x[i] = (long long)X[i-1];
y[i] = (long long)Y[i-1];
}
N = n;
process1();
}
int updateX(int pos, int val) {
pos++;
if(N <= 1000){ x[pos] = (long long)val; return process1(); }
if(pos < N-29){
sb3 *= inv(x[pos]);
sb3 %= MOD;
sb3 *= (long long)val;
sb3 %= MOD;
}
x[pos] = (long long)val;
subtask3();
return (int)ans;
}
int updateY(int pos, int val) {
pos++;
if(N <= 1000){ y[pos] = (long long)val; return process1(); }
y[pos] = (long long)val;
subtask3();
return (int)ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8900 KB |
Output is correct |
2 |
Correct |
0 ms |
8900 KB |
Output is correct |
3 |
Correct |
0 ms |
8900 KB |
Output is correct |
4 |
Correct |
0 ms |
8900 KB |
Output is correct |
5 |
Correct |
0 ms |
8900 KB |
Output is correct |
6 |
Correct |
0 ms |
8900 KB |
Output is correct |
7 |
Correct |
0 ms |
8900 KB |
Output is correct |
8 |
Correct |
0 ms |
8900 KB |
Output is correct |
9 |
Correct |
0 ms |
8900 KB |
Output is correct |
10 |
Correct |
0 ms |
8900 KB |
Output is correct |
11 |
Correct |
0 ms |
8900 KB |
Output is correct |
12 |
Correct |
0 ms |
8900 KB |
Output is correct |
13 |
Correct |
0 ms |
8900 KB |
Output is correct |
14 |
Correct |
0 ms |
8900 KB |
Output is correct |
15 |
Correct |
0 ms |
8900 KB |
Output is correct |
16 |
Correct |
0 ms |
8900 KB |
Output is correct |
17 |
Correct |
0 ms |
8900 KB |
Output is correct |
18 |
Correct |
0 ms |
8900 KB |
Output is correct |
19 |
Correct |
0 ms |
8900 KB |
Output is correct |
20 |
Correct |
0 ms |
8900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8900 KB |
Output is correct |
2 |
Correct |
0 ms |
8900 KB |
Output is correct |
3 |
Correct |
0 ms |
8900 KB |
Output is correct |
4 |
Correct |
0 ms |
8900 KB |
Output is correct |
5 |
Correct |
0 ms |
8900 KB |
Output is correct |
6 |
Correct |
0 ms |
8900 KB |
Output is correct |
7 |
Correct |
0 ms |
8900 KB |
Output is correct |
8 |
Correct |
0 ms |
8900 KB |
Output is correct |
9 |
Correct |
0 ms |
8900 KB |
Output is correct |
10 |
Correct |
0 ms |
8900 KB |
Output is correct |
11 |
Correct |
0 ms |
8900 KB |
Output is correct |
12 |
Correct |
0 ms |
8900 KB |
Output is correct |
13 |
Correct |
0 ms |
8900 KB |
Output is correct |
14 |
Correct |
0 ms |
8900 KB |
Output is correct |
15 |
Correct |
0 ms |
8900 KB |
Output is correct |
16 |
Correct |
0 ms |
8900 KB |
Output is correct |
17 |
Correct |
0 ms |
8900 KB |
Output is correct |
18 |
Correct |
0 ms |
8900 KB |
Output is correct |
19 |
Correct |
0 ms |
8900 KB |
Output is correct |
20 |
Correct |
0 ms |
8900 KB |
Output is correct |
21 |
Correct |
0 ms |
8900 KB |
Output is correct |
22 |
Correct |
0 ms |
8900 KB |
Output is correct |
23 |
Correct |
11 ms |
8900 KB |
Output is correct |
24 |
Correct |
7 ms |
8900 KB |
Output is correct |
25 |
Correct |
15 ms |
8900 KB |
Output is correct |
26 |
Correct |
15 ms |
8900 KB |
Output is correct |
27 |
Correct |
10 ms |
8900 KB |
Output is correct |
28 |
Correct |
13 ms |
8900 KB |
Output is correct |
29 |
Correct |
9 ms |
8900 KB |
Output is correct |
30 |
Correct |
11 ms |
8900 KB |
Output is correct |
31 |
Correct |
10 ms |
8900 KB |
Output is correct |
32 |
Correct |
10 ms |
8900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
12812 KB |
Output is correct |
2 |
Correct |
127 ms |
12812 KB |
Output is correct |
3 |
Correct |
61 ms |
12812 KB |
Output is correct |
4 |
Correct |
94 ms |
12812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8900 KB |
Output is correct |
2 |
Correct |
0 ms |
8900 KB |
Output is correct |
3 |
Correct |
0 ms |
8900 KB |
Output is correct |
4 |
Correct |
0 ms |
8900 KB |
Output is correct |
5 |
Correct |
0 ms |
8900 KB |
Output is correct |
6 |
Correct |
1 ms |
8900 KB |
Output is correct |
7 |
Correct |
0 ms |
8900 KB |
Output is correct |
8 |
Correct |
0 ms |
8900 KB |
Output is correct |
9 |
Correct |
0 ms |
8900 KB |
Output is correct |
10 |
Correct |
0 ms |
8900 KB |
Output is correct |
11 |
Correct |
0 ms |
8900 KB |
Output is correct |
12 |
Correct |
0 ms |
8900 KB |
Output is correct |
13 |
Correct |
0 ms |
8900 KB |
Output is correct |
14 |
Correct |
0 ms |
8900 KB |
Output is correct |
15 |
Correct |
0 ms |
8900 KB |
Output is correct |
16 |
Correct |
0 ms |
8900 KB |
Output is correct |
17 |
Correct |
0 ms |
8900 KB |
Output is correct |
18 |
Correct |
0 ms |
8900 KB |
Output is correct |
19 |
Correct |
0 ms |
8900 KB |
Output is correct |
20 |
Correct |
0 ms |
8900 KB |
Output is correct |
21 |
Correct |
0 ms |
8900 KB |
Output is correct |
22 |
Correct |
0 ms |
8900 KB |
Output is correct |
23 |
Correct |
11 ms |
8900 KB |
Output is correct |
24 |
Correct |
8 ms |
8900 KB |
Output is correct |
25 |
Correct |
15 ms |
8900 KB |
Output is correct |
26 |
Correct |
12 ms |
8900 KB |
Output is correct |
27 |
Correct |
10 ms |
8900 KB |
Output is correct |
28 |
Correct |
13 ms |
8900 KB |
Output is correct |
29 |
Correct |
9 ms |
8900 KB |
Output is correct |
30 |
Correct |
12 ms |
8900 KB |
Output is correct |
31 |
Correct |
10 ms |
8900 KB |
Output is correct |
32 |
Correct |
7 ms |
8900 KB |
Output is correct |
33 |
Incorrect |
26 ms |
12812 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8900 KB |
Output is correct |
2 |
Correct |
0 ms |
8900 KB |
Output is correct |
3 |
Correct |
0 ms |
8900 KB |
Output is correct |
4 |
Correct |
0 ms |
8900 KB |
Output is correct |
5 |
Correct |
0 ms |
8900 KB |
Output is correct |
6 |
Correct |
0 ms |
8900 KB |
Output is correct |
7 |
Correct |
0 ms |
8900 KB |
Output is correct |
8 |
Correct |
0 ms |
8900 KB |
Output is correct |
9 |
Correct |
0 ms |
8900 KB |
Output is correct |
10 |
Correct |
0 ms |
8900 KB |
Output is correct |
11 |
Correct |
0 ms |
8900 KB |
Output is correct |
12 |
Correct |
0 ms |
8900 KB |
Output is correct |
13 |
Correct |
0 ms |
8900 KB |
Output is correct |
14 |
Correct |
0 ms |
8900 KB |
Output is correct |
15 |
Correct |
0 ms |
8900 KB |
Output is correct |
16 |
Correct |
0 ms |
8900 KB |
Output is correct |
17 |
Correct |
0 ms |
8900 KB |
Output is correct |
18 |
Correct |
0 ms |
8900 KB |
Output is correct |
19 |
Correct |
0 ms |
8900 KB |
Output is correct |
20 |
Correct |
0 ms |
8900 KB |
Output is correct |
21 |
Correct |
0 ms |
8900 KB |
Output is correct |
22 |
Correct |
0 ms |
8900 KB |
Output is correct |
23 |
Correct |
9 ms |
8900 KB |
Output is correct |
24 |
Correct |
11 ms |
8900 KB |
Output is correct |
25 |
Correct |
12 ms |
8900 KB |
Output is correct |
26 |
Correct |
14 ms |
8900 KB |
Output is correct |
27 |
Correct |
10 ms |
8900 KB |
Output is correct |
28 |
Correct |
13 ms |
8900 KB |
Output is correct |
29 |
Correct |
9 ms |
8900 KB |
Output is correct |
30 |
Correct |
9 ms |
8900 KB |
Output is correct |
31 |
Correct |
10 ms |
8900 KB |
Output is correct |
32 |
Correct |
10 ms |
8900 KB |
Output is correct |
33 |
Correct |
45 ms |
12812 KB |
Output is correct |
34 |
Correct |
96 ms |
12812 KB |
Output is correct |
35 |
Correct |
80 ms |
12812 KB |
Output is correct |
36 |
Correct |
111 ms |
12812 KB |
Output is correct |
37 |
Incorrect |
30 ms |
12812 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |