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 "bits/stdc++.h"
#include "horses.h"
using namespace std;
const int MOD = 1e9+7;
int n;
vector<int> x, y;
//vector<vector<int>> dp(1001, vector<int>(10001, -1));
int solve(int h, int i, int curr)
{
if(i==n)
{
return curr;
}
if(h==0)
return curr;
int t = h*x[i];
int maxi = curr;
int j = 0;
maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);
j = t;
maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);
j = t-1;
maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);
j = 1;
maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);
j = t-2;
if(t>=2)
maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);
return maxi;
}
int init(int N, int X[], int Y[])
{
n = N;
x.assign(n, 0);
y.assign(n, 0);
for(int i = 0; i<n; i++)
{
x[i] = X[i];
y[i] = Y[i];
}
int res = solve(1, 0, 0);
return res;
}
int updateX(int pos, int val)
{
x[pos] = val;
int res = solve(1, 0, 0);
return res;
}
int updateY(int pos, int val)
{
y[pos] = val;
int res = solve(1, 0, 0);
return res;
}
# | 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... |