Submission #1240976

#TimeUsernameProblemLanguageResultExecution timeMemory
1240976edga1Horses (IOI15_horses)C++20
34 / 100
1596 ms8252 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...