# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204766 | TAISA_ | Horses (IOI15_horses) | C++14 | 31 ms | 12280 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;
using ll=long long;
int x[500000],y[500000];
int n;
const ll mod=1000000007LL;
int calc(){
vector<ll> s(n);
s[0]=x[0];
for(int i=1;i<n;i++){
s[i]=s[i-1]*x[i]%mod;
}
ll id=n-1,t=x[n-1];
for(int i=n-2;i>=0;i--){
if(y[i]>t*y[id]){
id=i;
t=1;
}
t*=x[i];
if(t>=mod){
break;
}
}
return y[id]*s[id]%mod;
}
int init(int N, int X[], int Y[]) {
n=N;
assert(n<=1000);
for(int i=0;i<n;i++){
x[i]=X[i];
y[i]=Y[i];
}
return calc();
}
int updateX(int pos, int val) {
x[pos]=val;
return calc();
}
int updateY(int pos, int val) {
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... |