# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251342 | DavidDamian | Horses (IOI15_horses) | C++11 | 0 ms | 0 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"
typedef long long ll;
#define mod 1000000007
int Y[500005];
int X[500005];
ll product[500005];
int n;
int init(int N, int y[], int x[]) {
n=N;
for(int i=0;i<n;i++){
X[i]=x[i];
Y[i]=y[i];
}
ll maximum=0;
product[0]=X[0];
maximum=X[0]*Y[0];
for(int i=1;i<n;i++){
product[i]=product[i-1]*X[i];
maximum=max(maximum,(ll)product[i]*(ll)Y[i]);
}
return maximum%mod;
}
int updateX(int pos, int val) {
ll maximum=0;
X[pos]=val;
product[0]=X[0];
maximum=X[0]*Y[0];
for(int i=1;i<n;i++){
product[i]=product[i-1]*X[i];
maximum=max(maximum,(ll)product[i]*(ll)Y[i]);
}
return maximum%mod;
}
int updateY(int pos, int val) {
ll maximum=0;
Y[pos]=val;
product[0]=X[0];
maximum=X[0]*Y[0];
for(int i=1;i<n;i++){
product[i]=product[i-1]*X[i];
maximum=max(maximum,(ll)product[i]*(ll)Y[i]);
}
}