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>
using namespace std;
size_t n;
int X[1 << 19], Y[1 << 19], Q[16][1024];
int compute()
{
for(size_t i = 0; i < 16; i++) for(size_t j = 0; j < 1024; j++) Q[i][j] = INT_MIN/3;
Q[0][1] = 0;
for(size_t i = 0; i < n; i++)
{
for(size_t k = 1024; k --> 0; )
{
if(k)
Q[i][k-1] = max(Q[i][k-1], Q[i][k] + Y[i]);
if(X[i]*k<1024)
Q[i+1][X[i]*k] = max(Q[i+1][X[i]*k], Q[i][k]);
}
}
int r = 0;
for(size_t k = 0; k < 1024; k++)
r = max(r, Q[n][k]);
return r;
}
int init(int _n, int x[], int y[])
{
n = _n;
copy(x, x + n, X);
copy(y, y + n, Y);
return compute();
}
int updateX(int pos, int val)
{
X[pos] = val;
return compute();
}
int updateY(int pos, int val)
{
Y[pos] = val;
return compute();
}
# | 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... |