# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
921663 | coding_snorlax | 말 (IOI15_horses) | C++14 | 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"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
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];
}
ll answer = 1,tmp=1,i=-1;
for(ll I=N-1;I>=0;I--){
if(tmp*X[I]>2000000000) {i=I;break;}
tmp *= X[I];
}
if(i==-1) i=0;
ll place = i;
ll Max=1,tmp2=1;
for(ll j=i;j<N;j++){
tmp2*=X[j];
tmp2*=Y[j];
if(tmp2>Max){
Max = tmp2;
place = j;
}
tmp2/=Y[j];
}
for(ll j=0;j<=place;j++){
answer*=X[j];
answer %= (1000000007);
}
answer*=Y[place];
answer %= 1000000007;
return answer;
}
int updateX(int pos, int val) {
x[pos]=val;
return init(n,x,y);
}
int updateY(int pos, int val) {
y[pos]=val;
return init(n,x,y);
}