# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438023 | illyakr | Horses (IOI15_horses) | C++14 | 1596 ms | 12060 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 <bits/stdc++.h>
#include "horses.h"
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll mx = 1000000000000000018;
ll n;
ll x[501010], y[501010];
int gt() {
ll cnt = y[n - 1];
ll last = n - 1;
for (int i = n - 1; i > 0; i--) {
if (x[i] > mx / cnt)cnt = mx;
else cnt *= x[i];
if (cnt < y[i - 1]){last = i - 1;cnt = y[i - 1];}
if (cnt == mx)break;
}
ll d = 1;
for (int i = 0; i <= last; i++) {
d = ((d % mod) * (x[i] % mod)) % mod;
}
return ((d % mod) * (y[last] % mod)) % mod;
}
int init(int N, int X[], int Y[]) {
n = N;
for (ll i = 0; i < n; i++) {
x[i] = X[i];
y[i] = Y[i];
}
return gt();
}
int updateX(int pos, int val) {
x[pos] = val;
return gt();
}
int updateY(int pos, int val) {
y[pos] = val;
return gt();
}
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... |