Submission #1172655

#TimeUsernameProblemLanguageResultExecution timeMemory
1172655HappyCapybaraHorses (IOI15_horses)C++17
37 / 100
233 ms40452 KiB
#include "horses.h" #include<bits/stdc++.h> using namespace std; #define ll __int128 ll m = 1000000007; int n; vector<int> x, y; vector<ll> st; void update(int pos, int val, int node=1, int tl=0, int tr=n-1){ if (tl == tr){ st[node] = val; return; } int tm = (tl+tr)/2; if (pos <= tm) update(pos, val, node*2, tl, tm); else update(pos, val, node*2+1, tm+1, tr); st[node] = (st[node*2]*st[node*2+1]) % m; } ll query(int l, int r, int node=1, int tl=0, int tr=n-1){ if (l <= tl && tr <= r) return st[node]; int tm = (tl+tr)/2; ll res = 1; if (l <= tm) res = (res*query(l, r, node*2, tl, tm)) % m; if (tm+1 <= r) res = (res*query(l, r, node*2+1, tm+1, tr)) % m; return res; } int solve(){ int z = max(0, n-35); ll cur = query(0, z), cy = y[z], cx = 1, bsf = (query(0, z)*y[z])%m; for (int i=z+1; i<n; i++){ cur = (cur*x[i]) % m; cx *= x[i]; if (cx * y[i] > cy){ bsf = (cur*y[i]) % m; cy = y[i]; cx = 1; } } return bsf; } int init(int N, int X[], int Y[]){ n = N; x.resize(n); y.resize(n); st.resize(4*n, 1); for (int i=0; i<n; i++){ x[i] = X[i]; y[i] = Y[i]; update(i, X[i]); } return solve(); } int updateX(int pos, int val){ x[pos] = val; update(pos, val); return solve(); } int updateY(int pos, int val){ y[pos] = val; return solve(); }
#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...