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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 545 , inf = 1e9 + 199 , mod = 1e9 + 7;
#include "horses.h"
ll n , x[N] , y[N];
long double xlog[N] , ylog[N];
int calc(){
long double curr = 1 , mx = 0;
ll ind=0;
for(int i=0;i<n;i++){
curr += xlog[i];
if(mx < curr + ylog[i]){
mx = curr + ylog[i];
ind = i;
}
}
ll res=1;
for(int i=0;i<=ind;i++){
res *= x[i];
res %= mod;
}
return (res*y[ind])%mod;
}
int init(int nn,int X[],int Y[]){
n=nn;
for(int i=0;i<n;i++){
x[i]=X[i];
xlog[i] = log(x[i]);
y[i]=Y[i];
ylog[i] = log(y[i]);
}
return calc();
}
int updateX(int pos,int val){
x[pos]=val;
xlog[pos] = log(x[pos]);
return calc();
}
int updateY(int pos,int val){
y[pos]=val;
ylog[pos] = log(y[pos]);
return calc();
}
Compilation message (stderr)
horses.cpp: In function 'int calc()':
horses.cpp:29:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
29 | return (res*y[ind])%mod;
| ~~~~~~~~~~~~^~~~
# | 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... |