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>
#define ll long long
#define ld long double
using namespace std;
const ll inf = 5e5+9,mod = 1e9+7;
ll n,dp[inf],x[inf],y[inf];
int calc(){
ld lcur=0.0,lret = 0.0,ltmp=0.0;
ll cur = 1,ret = 0,tmp=0;
for(int i=1;i<=n;i++){
cur = (cur*x[i])%mod;
lcur += log(1.0*x[i]);
tmp = (cur*y[i])%mod;
ltmp = lcur+log(1.0*y[i]);
if(ltmp>lret)
lret = ltmp,ret = tmp;
ret = max(ret , (cur*y[i])%mod );
}
return ret;
}
int init(int N, int X[], int Y[]) {
n = N;
for(int i=1;i<=N;i++)
x[i] = X[i-1] , y[i] = Y[i-1];
return calc();
}
int updateX(int pos, int val) {
pos++;
x[pos] = val;
return calc();
}
int updateY(int pos, int val) {
pos++;
y[pos] = val;
return calc();
}
Compilation message (stderr)
horses.cpp: In function 'int calc()':
horses.cpp:16:28: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
lcur += log(1.0*x[i]);
~~~^
horses.cpp:18:32: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
ltmp = lcur+log(1.0*y[i]);
~~~^
horses.cpp:23:9: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return ret;
^~~
# | 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... |