#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 5e5 + 10;
int n;
ll x[maxn], y[maxn];
int solve() {
ll prod = 1, last = 0, pref = 1, mx = 0;
for(int i = 0; i < n; i++) {
prod *= x[i];
pref = pref * x[i] % mod;
if((long double)y[i] * prod > last) {
mx = pref * y[i] % mod;
prod = 1; last = y[i];
}
} return mx;
}
int init(int N, int X[], int Y[]) {
n = 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:20:11: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
} return mx;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
496 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
6 |
Correct |
2 ms |
580 KB |
Output is correct |
7 |
Correct |
2 ms |
584 KB |
Output is correct |
8 |
Correct |
2 ms |
584 KB |
Output is correct |
9 |
Correct |
2 ms |
592 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
608 KB |
Output is correct |
14 |
Correct |
2 ms |
612 KB |
Output is correct |
15 |
Correct |
2 ms |
732 KB |
Output is correct |
16 |
Correct |
2 ms |
732 KB |
Output is correct |
17 |
Correct |
2 ms |
812 KB |
Output is correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Correct |
2 ms |
812 KB |
Output is correct |
20 |
Correct |
2 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
812 KB |
Output is correct |
2 |
Correct |
2 ms |
812 KB |
Output is correct |
3 |
Correct |
2 ms |
812 KB |
Output is correct |
4 |
Correct |
2 ms |
812 KB |
Output is correct |
5 |
Correct |
2 ms |
812 KB |
Output is correct |
6 |
Correct |
2 ms |
812 KB |
Output is correct |
7 |
Correct |
2 ms |
812 KB |
Output is correct |
8 |
Correct |
2 ms |
812 KB |
Output is correct |
9 |
Correct |
2 ms |
812 KB |
Output is correct |
10 |
Correct |
2 ms |
812 KB |
Output is correct |
11 |
Correct |
2 ms |
812 KB |
Output is correct |
12 |
Correct |
2 ms |
812 KB |
Output is correct |
13 |
Correct |
2 ms |
812 KB |
Output is correct |
14 |
Correct |
2 ms |
812 KB |
Output is correct |
15 |
Correct |
2 ms |
812 KB |
Output is correct |
16 |
Correct |
2 ms |
812 KB |
Output is correct |
17 |
Correct |
2 ms |
812 KB |
Output is correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Correct |
2 ms |
812 KB |
Output is correct |
20 |
Correct |
2 ms |
812 KB |
Output is correct |
21 |
Correct |
2 ms |
812 KB |
Output is correct |
22 |
Correct |
2 ms |
812 KB |
Output is correct |
23 |
Correct |
9 ms |
812 KB |
Output is correct |
24 |
Correct |
9 ms |
812 KB |
Output is correct |
25 |
Correct |
9 ms |
812 KB |
Output is correct |
26 |
Correct |
9 ms |
852 KB |
Output is correct |
27 |
Correct |
8 ms |
880 KB |
Output is correct |
28 |
Correct |
11 ms |
896 KB |
Output is correct |
29 |
Correct |
8 ms |
928 KB |
Output is correct |
30 |
Correct |
9 ms |
1068 KB |
Output is correct |
31 |
Correct |
8 ms |
1068 KB |
Output is correct |
32 |
Correct |
8 ms |
1068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1592 ms |
12864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
12864 KB |
Output is correct |
2 |
Correct |
2 ms |
12864 KB |
Output is correct |
3 |
Correct |
2 ms |
12864 KB |
Output is correct |
4 |
Correct |
2 ms |
12864 KB |
Output is correct |
5 |
Correct |
2 ms |
12864 KB |
Output is correct |
6 |
Correct |
2 ms |
12864 KB |
Output is correct |
7 |
Correct |
2 ms |
12864 KB |
Output is correct |
8 |
Correct |
2 ms |
12864 KB |
Output is correct |
9 |
Correct |
2 ms |
12864 KB |
Output is correct |
10 |
Correct |
2 ms |
12864 KB |
Output is correct |
11 |
Correct |
2 ms |
12864 KB |
Output is correct |
12 |
Correct |
2 ms |
12864 KB |
Output is correct |
13 |
Correct |
2 ms |
12864 KB |
Output is correct |
14 |
Correct |
2 ms |
12864 KB |
Output is correct |
15 |
Correct |
2 ms |
12864 KB |
Output is correct |
16 |
Correct |
2 ms |
12864 KB |
Output is correct |
17 |
Correct |
2 ms |
12864 KB |
Output is correct |
18 |
Correct |
2 ms |
12864 KB |
Output is correct |
19 |
Correct |
2 ms |
12864 KB |
Output is correct |
20 |
Correct |
2 ms |
12864 KB |
Output is correct |
21 |
Correct |
2 ms |
12864 KB |
Output is correct |
22 |
Correct |
2 ms |
12864 KB |
Output is correct |
23 |
Correct |
9 ms |
12864 KB |
Output is correct |
24 |
Correct |
9 ms |
12864 KB |
Output is correct |
25 |
Correct |
10 ms |
12864 KB |
Output is correct |
26 |
Correct |
10 ms |
12864 KB |
Output is correct |
27 |
Correct |
9 ms |
12864 KB |
Output is correct |
28 |
Correct |
10 ms |
12864 KB |
Output is correct |
29 |
Correct |
8 ms |
12864 KB |
Output is correct |
30 |
Correct |
9 ms |
12864 KB |
Output is correct |
31 |
Correct |
8 ms |
12864 KB |
Output is correct |
32 |
Correct |
8 ms |
12864 KB |
Output is correct |
33 |
Execution timed out |
1567 ms |
17092 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
17092 KB |
Output is correct |
2 |
Correct |
2 ms |
17092 KB |
Output is correct |
3 |
Correct |
2 ms |
17092 KB |
Output is correct |
4 |
Correct |
2 ms |
17092 KB |
Output is correct |
5 |
Correct |
2 ms |
17092 KB |
Output is correct |
6 |
Correct |
2 ms |
17092 KB |
Output is correct |
7 |
Correct |
2 ms |
17092 KB |
Output is correct |
8 |
Correct |
2 ms |
17092 KB |
Output is correct |
9 |
Correct |
2 ms |
17092 KB |
Output is correct |
10 |
Correct |
2 ms |
17092 KB |
Output is correct |
11 |
Correct |
2 ms |
17092 KB |
Output is correct |
12 |
Correct |
2 ms |
17092 KB |
Output is correct |
13 |
Correct |
2 ms |
17092 KB |
Output is correct |
14 |
Correct |
2 ms |
17092 KB |
Output is correct |
15 |
Correct |
2 ms |
17092 KB |
Output is correct |
16 |
Correct |
2 ms |
17092 KB |
Output is correct |
17 |
Correct |
2 ms |
17092 KB |
Output is correct |
18 |
Correct |
2 ms |
17092 KB |
Output is correct |
19 |
Correct |
2 ms |
17092 KB |
Output is correct |
20 |
Correct |
2 ms |
17092 KB |
Output is correct |
21 |
Correct |
2 ms |
17092 KB |
Output is correct |
22 |
Correct |
2 ms |
17092 KB |
Output is correct |
23 |
Correct |
9 ms |
17092 KB |
Output is correct |
24 |
Correct |
9 ms |
17092 KB |
Output is correct |
25 |
Correct |
9 ms |
17092 KB |
Output is correct |
26 |
Correct |
9 ms |
17092 KB |
Output is correct |
27 |
Correct |
8 ms |
17092 KB |
Output is correct |
28 |
Correct |
9 ms |
17092 KB |
Output is correct |
29 |
Correct |
9 ms |
17092 KB |
Output is correct |
30 |
Correct |
9 ms |
17092 KB |
Output is correct |
31 |
Correct |
8 ms |
17092 KB |
Output is correct |
32 |
Correct |
8 ms |
17092 KB |
Output is correct |
33 |
Execution timed out |
1584 ms |
17092 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |