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>
#include "horses.h"
#define MAXN 500007
using namespace std;
const long long mod=1e9+7;
int n;
long long x[MAXN],y[MAXN];
int calc(){
int best=0;
long long mult=1;
for(int i=1;i<=n;i++){
mult*=x[i];
if(mult>mod or mult*y[i]>y[best]){
best=i;
mult=1;
}
}
mult=1;
for(int i=1;i<=best;i++){
mult*=x[i]; mult%=mod;
}
mult*=y[best]; mult%=mod;
return mult;
}
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) {
x[pos+1]=val;
return calc();
}
int updateY(int pos, int val) {
y[pos+1]=val;
return calc();
}
/*int main(){
init(3,{2,1,3},{3,4,1});
cout<<updateY(1,2)<<"\n";
return 0;
}*/
Compilation message (stderr)
horses.cpp: In function 'int calc()':
horses.cpp:30:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
30 | return mult;
| ^~~~
# | 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... |