# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283277 | stoyan_malinin | Horses (IOI15_horses) | C++14 | 109 ms | 13944 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 <cmath>
#include <vector>
#include <iostream>
using namespace std;
const int MAXN = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int x[MAXN], y[MAXN];
long long evalBest()
{
double lnSum = 0;
pair <double, int> opt = {-1, -1};
for(int i = 0;i<n;i++)
{
lnSum += log(x[i]);
if(lnSum+log(y[i])>opt.first)
{
opt = {lnSum+log(y[i]), i};
}
}
long long product = 1;
for(int i = 0;i<=opt.second;i++) product = (product*1LL*x[i])%mod;
return (product*y[opt.second])%mod;
}
int init(int N, int X[], int Y[])
{
n = N;
for(int i = 0;i<n;i++)
{
x[i] = X[i];
y[i] = Y[i];
}
return evalBest();
}
int updateX(int pos, int val)
{
x[pos] = val;
return evalBest();
}
int updateY(int pos, int val)
{
y[pos] = val;
return evalBest();
}
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... |