# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636981 | iee | Sličice (COCI19_slicice) | C++17 | 45 ms | 1272 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.
// 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |