Submission #636981

#TimeUsernameProblemLanguageResultExecution timeMemory
636981ieeSličice (COCI19_slicice)C++17
90 / 90
45 ms1272 KiB
// iee #include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a), i##END = (b); i <= (i##END); ++i) #define per(i, a, b) for (int i = (a); i >= (b); --i) #define fi first #define se second using ll = long long; using ull = unsigned long long; using namespace std; void work(int); template <class T> void read(T &x) { x = 0; int f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + (ch - '0'); ch = getchar(); } x *= f; } int main() { int TT = 1; // cin >> TT; rep(CAS, 1, TT) work(CAS); return 0; } const int N = 505; int n, m, k, p[N], b[N], f[N][N]; void work(int CASE) { cin >> n >> m >> k; rep(i, 1, n) cin >> p[i]; rep(i, 0, m) cin >> b[i]; rep(i, 1, n) rep(j, 0, k) rep(t, 0, min({m - p[i], k, j})) f[i][j] = max(f[i][j], f[i - 1][j - t] + b[p[i] + t]); cout << *max_element(f[n], f[n] + N); }
#Verdict Execution timeMemoryGrader output
Fetching results...