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>
#define ll long long
using namespace std;
const ll inf = 1e3+9,mod = 1e9+7;
ll n,dp[inf],x[inf],y[inf];
int calc(){
ll cur = 1,ret = 0;
for(int i=1;i<=n;i++){
dp[i] = 0;
cur = 1;
for(int j=i;j>0;j--){
cur = (cur*x[j])%mod;
dp[i] = max(dp[i], (mod+dp[j-1]-y[j-1] + (cur*y[i])%mod)%mod );
}
ret = max( ret ,dp[i] );
//cout<<dp[i]<<" ";
}
return (int)ret;
}
int init(int N, int X[], int Y[]) {
n = N;
for(int i=1;i<=N;i++)
x[i] = X[i-1] , y[i] = Y[i-1];
return calc();
}
int updateX(int pos, int val) {
pos++;
x[pos] = val;
return calc();
}
int updateY(int pos, int val) {
pos++;
y[pos] = val;
return calc();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |