# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68962 | theknife2001 | Horses (IOI15_horses) | C++17 | 1569 ms | 16296 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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N=5e5+55;
long long x[N];
long long y[N];
long long s[N];
int n;
int m=1e9+7;
int solve()
{
int i=N-1;
long long ret=0;
long long temp=1;
while(i--)
{
s[i]=x[i]*s[i+1];
if(s[i]>1e9)
break;
}
if(i==-1)
i=0;
int bestpos=n-1;
for(;i<n;i++)
{
temp*=x[i];
if(y[i]>s[i+1]&&y[i]*temp>ret)
{
ret=y[i]*temp;
bestpos=i;
}
}
ret=1;
for(int i=0;i<=bestpos;i++)
{
ret*=x[i];
ret%=m;
}
ret*=y[bestpos];
return (ret%m);
}
int init(int N, int X[], int Y[])
{
n=N;
for(int i=0;i<N;i++)
{
s[i]=1;
x[i]=X[i];
y[i]=Y[i];
}
s[n]=1;
return solve();
}
int updateX(int pos, int val) {
x[pos]=val;
return solve();
}
int updateY(int pos, int val)
{
y[pos]=val;
return solve();
}
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... |