# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
597045 |
2022-07-15T12:21:53 Z |
PiejanVDC |
Horses (IOI15_horses) |
C++17 |
|
1500 ms |
12256 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
vector<long long>x,y;
long long mod = (long long)1000000007;
int init(int n, int X[], int Y[]) {
for(int i = 0 ; i < n ; i++)
x.push_back(X[i]), y.push_back(Y[i]);
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
got %= mod;
if((y[i]%mod * (got-1)%mod)%mod > prev%mod)
last = i, prev = y[i] * (got-1);
prev %= mod;
// + case where you sell all of them
ans = max(ans, (curr%mod + (y[i]%mod * got%mod)%mod)%mod);
ans %= mod;
}
curr += prev;
curr %= mod;
prev = -1;
got = 1;
}
ans = max(ans, curr);
assert(ans >= 0);
return ans%mod;
}
int updateX(int p, int val) {
int n = (int)x.size();
x[p] = val;
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
got %= mod;
if((y[i]%mod * (got-1)%mod)%mod > prev%mod)
last = i, prev = y[i] * (got-1);
prev %= mod;
// + case where you sell all of them
ans = max(ans, (curr%mod + (y[i]%mod * got%mod)%mod)%mod);
ans %= mod;
}
curr += prev;
curr %= mod;
prev = -1;
got = 1;
}
ans = max(ans, curr);
assert(ans >= 0);
return ans%mod;
}
int updateY(int p, int val) {
int n = (int)x.size();
y[p] = val;
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
got %= mod;
if((y[i]%mod * (got-1)%mod)%mod > prev%mod)
last = i, prev = y[i] * (got-1);
prev %= mod;
// + case where you sell all of them
ans = max(ans, (curr%mod + (y[i]%mod * got%mod)%mod)%mod);
ans %= mod;
}
curr += prev;
curr %= mod;
prev = -1;
got = 1;
}
ans = max(ans, curr);
assert(ans >= 0);
return ans%mod;
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:37:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
37 | return ans%mod;
| ~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:69:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
69 | return ans%mod;
| ~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:101:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
101 | return ans%mod;
| ~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
1 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 |
0 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 |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
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 |
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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1591 ms |
12256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
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 |
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 |
1 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 |
1 ms |
240 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 |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |