#include "horses.h"
int n;
int *x;
int *y;
int mod = 1e9+7;
int finans(){
int mx = 0;
long long curr = 1;
for(int i = 0;i<n;i++){
curr*=x[i];
if(curr>y[mx]){
mx=i;
curr=1;
continue;
}
else if(curr*y[i]>y[mx]){
mx=i;
curr=1;
continue;
}
}
long long ans = 1;
for(int i = 0;i<=mx;i++){
ans*=x[i];
ans%=mod;
}
ans*=y[mx];
ans%=mod;
return ans;
}
int init(int N, int X[], int Y[]) {
x=X;
y=Y;
n=N;
return finans();
}
int updateX(int pos, int val) {
x[pos]=val;
return finans();
}
int updateY(int pos, int val) {
y[pos]=val;
return finans();
}
Compilation message
horses.cpp: In function 'int finans()':
horses.cpp:31:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
31 | return ans;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
564 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
504 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
428 KB |
Output is correct |
14 |
Correct |
1 ms |
508 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
0 ms |
336 KB |
Output is correct |
18 |
Correct |
0 ms |
336 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
0 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
428 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
504 KB |
Output is correct |
14 |
Correct |
0 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
9 ms |
336 KB |
Output is correct |
24 |
Correct |
8 ms |
336 KB |
Output is correct |
25 |
Correct |
9 ms |
336 KB |
Output is correct |
26 |
Correct |
9 ms |
336 KB |
Output is correct |
27 |
Correct |
7 ms |
336 KB |
Output is correct |
28 |
Correct |
8 ms |
336 KB |
Output is correct |
29 |
Correct |
6 ms |
336 KB |
Output is correct |
30 |
Correct |
6 ms |
336 KB |
Output is correct |
31 |
Correct |
5 ms |
592 KB |
Output is correct |
32 |
Correct |
6 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1562 ms |
6492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
0 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
504 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
0 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
504 KB |
Output is correct |
23 |
Correct |
8 ms |
460 KB |
Output is correct |
24 |
Correct |
8 ms |
336 KB |
Output is correct |
25 |
Correct |
9 ms |
336 KB |
Output is correct |
26 |
Correct |
9 ms |
468 KB |
Output is correct |
27 |
Correct |
8 ms |
504 KB |
Output is correct |
28 |
Correct |
8 ms |
452 KB |
Output is correct |
29 |
Correct |
6 ms |
336 KB |
Output is correct |
30 |
Correct |
6 ms |
336 KB |
Output is correct |
31 |
Correct |
5 ms |
336 KB |
Output is correct |
32 |
Correct |
6 ms |
336 KB |
Output is correct |
33 |
Execution timed out |
1567 ms |
8016 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
424 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
336 KB |
Output is correct |
17 |
Correct |
0 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
508 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
504 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
8 ms |
336 KB |
Output is correct |
24 |
Correct |
8 ms |
504 KB |
Output is correct |
25 |
Correct |
9 ms |
336 KB |
Output is correct |
26 |
Correct |
9 ms |
468 KB |
Output is correct |
27 |
Correct |
8 ms |
336 KB |
Output is correct |
28 |
Correct |
8 ms |
460 KB |
Output is correct |
29 |
Correct |
6 ms |
440 KB |
Output is correct |
30 |
Correct |
6 ms |
456 KB |
Output is correct |
31 |
Correct |
5 ms |
336 KB |
Output is correct |
32 |
Correct |
6 ms |
336 KB |
Output is correct |
33 |
Execution timed out |
1539 ms |
6480 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |