Submission #112150

#TimeUsernameProblemLanguageResultExecution timeMemory
112150dolphingarlicSličice (COCI19_slicice)C++14
90 / 90
94 ms2424 KiB
#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 timeMemoryGrader output
Fetching results...