#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
vector<int> x, y;
int n;
int solve(){
ll hv = 1;
for(int i = 0; i < n; i++){
hv = hv * x[i] % mod;
ll pre = 1;
ll bst = 0;
for(int j = i + 1; j < n; j++){
if(bst == -1) break;
pre *= x[j];
if(pre > 1e9) bst = -1;
else bst = max(bst, pre * y[j]);
}
if(bst != -1 && y[i] > bst){
return hv * y[i] % mod;
}
}
}
int init(int N, int X[], int Y[]) {
n = N;
x.resize(n), y.resize(n);
for(int i = 0; i < n; i++){
x[i] = X[i];
y[i] = Y[i];
}
return solve();
}
int updateX(int pos, int val) {
x[pos] = val;
return solve();
}
int updateY(int pos, int val) {
y[pos] = val;
return solve();
}
Compilation message
horses.cpp: In function 'int solve()':
horses.cpp:19:7: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
19 | if(pre > 1e9) bst = -1;
| ^~~
horses.cpp:23:21: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
23 | return hv * y[i] % mod;
| ~~~~~~~~~~^~~~~
horses.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
26 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
62 ms |
292 KB |
Output is correct |
24 |
Correct |
63 ms |
300 KB |
Output is correct |
25 |
Correct |
5 ms |
320 KB |
Output is correct |
26 |
Correct |
5 ms |
212 KB |
Output is correct |
27 |
Correct |
409 ms |
428 KB |
Output is correct |
28 |
Correct |
32 ms |
316 KB |
Output is correct |
29 |
Correct |
703 ms |
292 KB |
Output is correct |
30 |
Correct |
127 ms |
304 KB |
Output is correct |
31 |
Correct |
186 ms |
292 KB |
Output is correct |
32 |
Correct |
519 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1559 ms |
8144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
216 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
62 ms |
292 KB |
Output is correct |
24 |
Correct |
69 ms |
292 KB |
Output is correct |
25 |
Correct |
6 ms |
212 KB |
Output is correct |
26 |
Correct |
6 ms |
212 KB |
Output is correct |
27 |
Correct |
401 ms |
300 KB |
Output is correct |
28 |
Correct |
37 ms |
312 KB |
Output is correct |
29 |
Correct |
712 ms |
292 KB |
Output is correct |
30 |
Correct |
130 ms |
304 KB |
Output is correct |
31 |
Correct |
186 ms |
308 KB |
Output is correct |
32 |
Correct |
543 ms |
300 KB |
Output is correct |
33 |
Execution timed out |
1567 ms |
8048 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
63 ms |
308 KB |
Output is correct |
24 |
Correct |
62 ms |
212 KB |
Output is correct |
25 |
Correct |
5 ms |
212 KB |
Output is correct |
26 |
Correct |
5 ms |
212 KB |
Output is correct |
27 |
Correct |
404 ms |
292 KB |
Output is correct |
28 |
Correct |
31 ms |
212 KB |
Output is correct |
29 |
Correct |
689 ms |
296 KB |
Output is correct |
30 |
Correct |
124 ms |
296 KB |
Output is correct |
31 |
Correct |
192 ms |
300 KB |
Output is correct |
32 |
Correct |
532 ms |
328 KB |
Output is correct |
33 |
Execution timed out |
1568 ms |
8124 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |