제출 #1241028

#제출 시각아이디문제언어결과실행 시간메모리
1241028edga1말 (IOI15_horses)C++20
37 / 100
123 ms13336 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,preh=1,st[1050000]; inline int times(int a, int b){return 1LL*a*b%MOD;} void update(int x, int xl, int xr, int pos, int val){ if(xl==xr){ st[x]=val; return; } int mid=(xl+xr)/2; if(pos<=mid) update(x*2+1,xl,mid,pos,val); else update(x*2+2,mid+1,xr,pos,val); st[x]=times(st[x*2+1],st[x*2+2]); return; } int sum(int x, int xl, int xr, int l, int r){ if(xl>=l && xr<=r) return st[x]; if(xl>r || xr<l) return 1; int mid=(xl+xr)/2; return times(sum(x*2+1,xl,mid,l,r),sum(x*2+2,mid+1,xr,l,r)); } int findbesti(){ ll besti=n-1,tot=x[n-1]; for(int i=n-2; i>=max(0,n-30); i--){ if(y[i]>tot*y[besti]){ besti=i; tot=1; } tot*=x[i]; if(tot>=1e9) break; } return besti; } int calculate(){ int besti=findbesti(); return times(sum(0,0,n-1,0,besti),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]; update(0,0,n-1,i,x[i]); } return calculate(); } int updateX(int pos, int val) { x[pos]=val; update(0,0,n-1,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...