# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1129509 | boris_7 | Horses (IOI15_horses) | C++20 | 0 ms | 0 KiB |
if(n<=1000){
ll ans = 1,cnt=1,ind = 0;
for(int i = 0;i<n;i++){
cnt*=x[i];
if(cnt*y[i]>=y[ind]) ind = i,cnt=1;
}
for(int i = 0;i<=ind;i++) ans=(ans*x[i])%mod;
ans*=y[ind];
return ans%mod;
}
else{
ll ans = 1,cnt=1,ind = n-41;
for(int i = n-40;i<n;i++){
cnt*=x[i];
if(cnt*y[i]>=y[ind]) ind = i,cnt=1;
}
for(int i = 0;i<=ind;i++) ans=(ans*x[i])%mod;
ans*=y[ind];
return ans%mod;
}