# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112150 | dolphingarlic | Sličice (COCI19_slicice) | C++14 | 94 ms | 2424 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>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#pragma GCC optimize("O3")
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n, m, l;
ll q[501], B[501];
ll dp[501][501]; // dp[i][j] = Max num of points after i teams
// and still have j cards remaining.
cin >> n >> m >> l;
FOR(i, 1, n + 1) {
cin >> q[i];
}
FOR(i, 0, m + 1) {
cin >> B[i];
}
fill(dp[0], dp[0] + 501, 0);
FOR(i, 1, n + 1) {
FOR(j, 0, l + 1) {
dp[i][j] = 0;
FOR(k, 0, l - j + 1) {
// Give k cards to team i
dp[i][j] = max(dp[i][j], dp[i - 1][j + k] + B[min(m, q[i] + k)]);
}
}
}
cout << *max_element(dp[n], dp[n] + l + 1) << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |