#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD=1e9+7, MAXN=5e5+5;
int x[MAXN],y[MAXN],n;
inline int times(int a, int b){return 1LL*a*b%MOD;}
int calculate(){
ll besti=n-1,tot=x[n-1];
for(int i=n-2; i>=0; i--){
if(y[i]>tot*y[besti]){
besti=i;
tot=1;
}
tot*=x[i];
if(tot>=1e9) break;
}
int h=1;
for(int i=0; i<=besti; i++){
h=times(h,x[i]);
}
return times(h,y[besti]);
}
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 calculate();
}
int updateX(int pos, int val) {
x[pos]=val;
return calculate();
}
int updateY(int pos, int val) {
y[pos]=val;
return calculate();
}
# | 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... |