# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314120 | 2020-10-18T13:42:57 Z | phathnv | Sličice (COCI19_slicice) | C++11 | 66 ms | 384 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "SLCICE" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 501; int n, m, k, p[N], b[N], dp[2][N]; void readInput(){ cin >> n >> m >> k; for(int i = 1; i <= n; i++) cin >> p[i]; for(int i = 0; i <= m; i++) cin >> b[i]; } void solve(){ for(int i = 1; i <= n; i++){ int id = i & 1; for(int j = p[i]; j <= m; j++) for(int c = 0; c <= k; c++){ if (c + j - p[i] > k) break; dp[id][c + j - p[i]] = max(dp[id][c + j - p[i]], dp[id ^ 1][c] + b[j]); } } cout << dp[n & 1][k]; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 59 ms | 376 KB | Output is correct |
4 | Correct | 61 ms | 384 KB | Output is correct |
5 | Correct | 63 ms | 384 KB | Output is correct |
6 | Correct | 61 ms | 380 KB | Output is correct |
7 | Correct | 58 ms | 376 KB | Output is correct |
8 | Correct | 62 ms | 376 KB | Output is correct |
9 | Correct | 58 ms | 376 KB | Output is correct |
10 | Correct | 66 ms | 384 KB | Output is correct |