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>
using namespace std;
#define ll long long int
int n;
int x[500005]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
int y[500005]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
int init(int N, int X[], int Y[]) {
n=N;
for(ll i=0;i<N;i++){
x[i]=X[i];
y[i]=Y[i];
}
ll answer = 1,tmp=1,i=-1;
for(ll I=N-1;I>=0;I--){
if(tmp*X[I]>2000000000) {i=I;break;}
tmp *= X[I];
}
if(i==-1) i=0;
ll place = i;
ll Max=1,tmp2=1;
for(ll j=i;j<N;j++){
tmp2*=X[j];
tmp2*=Y[j];
if(tmp2>Max){
Max = tmp2;
place = j;
}
tmp2/=Y[j];
}
for(ll j=0;j<=place;j++){
answer*=X[j];
answer %= (1000000007);
}
answer*=Y[place];
answer %= 1000000007;
return answer;
}
int updateX(int pos, int val) {
x[pos]=val;
return init(n,x,y);
}
int updateY(int pos, int val) {
y[pos]=val;
return init(n,x,y);
}
Compilation message (stderr)
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:37:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
37 | return answer;
| ^~~~~~
# | 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... |