# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592229 | l_reho | Horses (IOI15_horses) | C++14 | 1587 ms | 8020 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>
using namespace std;
vector<int> A, B;
int L;
long long MOD = 1000000007;
long long modMult(long long a, long long b){
a %= MOD;
b %= MOD;
return ((a%MOD)*(b%MOD))%MOD;
}
long long test(){
long long curr = 1;
long long best = 0;
long long pos = -1;
for(int i = 0; i < L; i++){
curr = modMult(curr, A[i]);
if(modMult(curr, B[i]) >= best){
best = B[i];
curr = 1;
pos = i;
}
}
long long ans = 1LL;
for(int i = 0; i <= pos; i++){
ans = modMult(ans, A[i]);
}
ans = modMult(ans, B[pos]);
return ans%MOD;
}
int init(int N, int X[], int Y[]) {
A.assign(N, 0);
B.assign(N, 0);
L = N;
for(int i = 0; i < N; i++) A[i] = X[i], B[i] = Y[i];
return test();
}
int updateX(int pos, int val) {
A[pos] = val;
return test();
}
int updateY(int pos, int val) {
B[pos] = val;
return test();
}
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... |