# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97892 | someone_aa | Horses (IOI15_horses) | C++17 | 22 ms | 11520 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>
#define ll long long
using namespace std;
const int maxn = 100100;
const ll mod = 1e9 + 7;
ll x[maxn], y[maxn], n;
int solve() {
ll h = 1LL;
ll result = (1LL * x[0] * y[0])%mod;
ll prod = 1LL;
ll pref = x[0];
ll ind = 0;
for(int i=1;i<n;i++) {
prod *= x[i];
ll curr = prod * y[i];
pref *= x[i]; pref %= mod;
if(curr >= y[ind]) {
// buy this one
result = (pref * y[ind])%mod;
prod = 1LL;
ind = i;
}
else {
prod *= x[i];
}
}
return result%mod;
}
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 (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... |