This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include "horses.h"
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
const long long MOD=1e9+7;
ll x[500005],y[500005],n;
ll solve(){
long double nb=log(1.0),ans=0.0,temp=0.0;
ll NB=1,ANS=0,TEMP=0.0;
for (ll i = 0; i <min((int)n,31); ++i)
{
nb+=log(1.0*x[i]);
NB=((NB%MOD)*(x[i]%MOD))%MOD;
temp=nb+log(1.0*y[i]);
TEMP=(NB*y[i])%MOD;
if(temp>=ans){
ans=temp;
ANS=TEMP;
}
}
return ANS;
}
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 (int)solve();
}
int updateX(int pos, int val) {
x[pos]=val;
return (int)solve();
}
int updateY(int pos, int val) {
y[pos]=val;
return (int)solve();
}
Compilation message (stderr)
horses.cpp: In function 'long long unsigned int solve()':
horses.cpp:11:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (ll i = 0; i <min((int)n,31); ++i)
~~^~~~~~~~~~~~~~~
horses.cpp:13:18: warning: conversion to 'double' from 'long long unsigned int' may alter its value [-Wconversion]
nb+=log(1.0*x[i]);
~~~^
horses.cpp:15:22: warning: conversion to 'double' from 'long long unsigned int' may alter its value [-Wconversion]
temp=nb+log(1.0*y[i]);
~~~^| # | 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... |