# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298744 | Haunted_Cpp | Horses (IOI15_horses) | C++17 | 26 ms | 12288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 5;
const int MOD = 1e9 + 7;
vector<int> _X, _Y;
int _N;
int mult(int a, int b) {
long long res = 1LL * a * b;
if (res >= MOD) res %= MOD;
return res;
}
int solve() {
int where = 0;
int best_multiplier = 0;
long long road = 1;
for (int i = 0; i < _N; i++) {
long long nxt = 1LL * road * _X[i];
if (nxt >= best_multiplier || (1LL * nxt * _Y[i] >= best_multiplier) ) {
where = i;
best_multiplier = _Y[i];
road = 1;
continue;
}
road = nxt;
}
int horses = 1;
for (int i = 0; i <= where; i++) {
horses = mult(horses, _X[i]);
}
return mult(horses, _Y[where]);
}
int init(int N, int X[], int Y[]) {
assert(N <= MAX_N);
_N = N;
_X = _Y = vector<int>(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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |