# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
512541 | AdamGS | 말 (IOI15_horses) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
const ll MOD=1e9+7;
ll X[LIM], Y[LIM], n;
ll solve() {
ll p=1, k=n;
while(p<MOD && k>0) {
--k;
p*=X[k];
}
if(p>=MOD) ++k;
p=1;
ll ans=
rep(i, k) x=(x*X[i])%MOD;
while(k<n) {
p*=X[k];
ans=max(ans, p*Y[k]);
++k;
}
ans%=MOD;
ans=(ans*x)%MOD;
return ans;
}
int init(int D, int A[], int B[]) {
n=D;
rep(i, n) {
X[i]=A[i];
Y[i]=B[i];
}
return solve();
}
int updateX(int pos, int val) {
X[pos]=val;
return solve();
}
int updateY(int pos, int val) {
Y[pos]=val;
return solve();
}