# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100261 | Milki | Sličice (COCI19_slicice) | C++14 | 139 ms | 2396 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<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<int, int> point;
const int mod = 1e9 + 7, inf = 1e9, MAXN = 505, off = 1 << 18;
int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}
int n, m, k;
int p[MAXN], val[MAXN];
ll dp[MAXN][MAXN];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m >> k;
REP(i, n) cin >> p[i];
REP(i, m + 1) cin >> val[i];
REP(i, min(k + 1, m - p[0] + 1)) dp[0][i] = val[ min(p[0] + i, m) ];
FOR(i, 1, n) REP(j, k + 1) REP(last, m - p[i] + 1){
if(j - last < 0) continue;
dp[i][j] = max(dp[i][j], dp[i - 1][j - last] + val[ p[i] + last ] );
}
cout << dp[n - 1][k];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |