# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314120 | phathnv | Sličice (COCI19_slicice) | C++11 | 66 ms | 384 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 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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |