Submission #100261

#TimeUsernameProblemLanguageResultExecution timeMemory
100261MilkiSličice (COCI19_slicice)C++14
90 / 90
139 ms2396 KiB
#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 timeMemoryGrader output
Fetching results...