제출 #247413

#제출 시각아이디문제언어결과실행 시간메모리
247413ernestvw말 (IOI15_horses)C++11
34 / 100
131 ms13348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; int n; vector<ll> C, P; ll preprod = 1; int solve() { ll prod = C[n - 1]; int best = n - 1; long double ldprod = (long double)C[n-1]; for(int i = n - 2; i >= 0; --i) { prod *= C[i]; ldprod *= C[i]; long double x = ldprod * (long double)P[best]; if(x >= 1.5e18) break; if(prod * P[best] <= C[i] * P[i]) { best = i; prod = C[i]; ldprod = (long double)C[i]; } } prod = 1; if(n > 1000) { if(best < n - 100) exit(1); prod = preprod; for(int i = n - 100; i <= best; ++i) prod = (prod * C[i]) % mod; prod = (prod * P[best]) % mod; return int(prod % mod); } for(int i = 0; i <= best; ++i) { prod *= C[i]; prod %= mod; } prod *= P[best]; prod %= mod; return int(prod % mod); } int init(int N, int X[], int Y[]) { n = N; C.resize(n); P.resize(n); for(int i = 0; i < n; ++i) C[i] = X[i]; for(int i = 0; i < n; ++i) P[i] = Y[i]; if(n > 1000) { preprod = 1; for(int i = 0; i < n - 100; ++i) { preprod *= C[i]; preprod %= mod; } } return solve(); } int updateX(int pos, int val) { C[pos] = val; return solve(); } int updateY(int pos, int val) { P[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...