Submission #112150

# Submission time Handle Problem Language Result Execution time Memory
112150 2019-05-17T15:48:58 Z dolphingarlic Sličice (COCI19_slicice) C++14
90 / 90
94 ms 2424 KB
#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
1 Correct 3 ms 2304 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 94 ms 2424 KB Output is correct
4 Correct 72 ms 2280 KB Output is correct
5 Correct 73 ms 2296 KB Output is correct
6 Correct 78 ms 2424 KB Output is correct
7 Correct 80 ms 2300 KB Output is correct
8 Correct 72 ms 2296 KB Output is correct
9 Correct 73 ms 2296 KB Output is correct
10 Correct 76 ms 2296 KB Output is correct