# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764781 | SanguineChameleon | Horses (IOI15_horses) | C++17 | 1577 ms | 11960 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 mod = 1e9 + 7;
int mul(int a, int b) {
if (a > mod / b) {
return mod;
}
else {
return a * b;
}
}
const int maxN = 5e5 + 20;
int X[maxN];
int Y[maxN];
int N;
int calc() {
int best = 1;
int gain = 1;
for (int i = 2; i <= N; i++) {
gain = mul(gain, X[i]);
if (mul(gain, Y[i]) > Y[best]) {
best = i;
gain = 1;
}
}
int res = 1;
for (int i = 1; i <= best; i++) {
res = 1LL * res * X[i] % mod;
}
res = 1LL * res * Y[best] % mod;
return res;
}
int init(int _N, int _X[], int _Y[]) {
N = _N;
for (int i = 1; i <= N; i++) {
X[i] = _X[i - 1];
Y[i] = _Y[i - 1];
}
return calc();
}
int updateX(int pos, int val) {
pos++;
X[pos] = val;
return calc();
}
int updateY(int pos, int val) {
pos++;
Y[pos] = val;
return calc();
}
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... |