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>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef __int128 ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x,begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
int N,X[500010],Y[500010];
int solve(){
ll p=N-1,rui=1;
for(int i=N-1;i>=0;i--){
rui*=(ll)X[i];
if(rui>(ll)2e9)break;
p=i;
}
ll ans=0;
rui=1;
for(int i=p;i<N;i++){
rui*=(ll)X[i];
assert(rui<=2e9);
chmax(ans,rui*(ll)Y[i]);
}
ans%=mod;
rep(i,p)ans=ans*(ll)X[i]%mod;
if(ans<0)ans+=mod;
return ans;
}
int init(int n,int x[],int y[]){
N=n;
rep(i,N)X[i]=x[i],Y[i]=y[i];
return solve();
}
int updateX(int pos,int val){
X[pos]=val;
return solve();
}
int updateY(int pos,int val){
Y[pos]=val;
return solve();
}/*
int main(){
cin>>N;
rep(i,N)cin>>X[i];
rep(i,N)cin>>Y[i];
while(1){
string type; ll pos,val;
cin>>type>>pos>>val;
if(type=="X")cout<<updateX(pos,val)<<endl;
if(type=="Y")cout<<updateY(pos,val)<<endl;
}
}*/
Compilation message (stderr)
horses.cpp: In function 'int solve()':
horses.cpp:25:12: warning: conversion to 'int' from 'll {aka __int128}' may alter its value [-Wconversion]
for(int i=p;i<N;i++){
^
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from horses.cpp:2:
horses.cpp:27:15: warning: conversion to 'double' from 'll {aka __int128}' may alter its value [-Wconversion]
assert(rui<=2e9);
^
horses.cpp:33:9: warning: conversion to 'int' from 'll {aka __int128}' may alter its value [-Wconversion]
return ans;
^~~
# | 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... |