# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314457 | shrek12357 | Sličice (COCI19_slicice) | C++14 | 159 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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
const int MAXN = 505;
vector<int> dp(MAXN);
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<int> curs;
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
curs.push_back(temp);
}
vector<int> vals;
for (int i = 0; i < m + 1; i++) {
int temp;
cin >> temp;
vals.push_back(temp);
}
for (int i = 0; i < n; i++) {
vector<int> temp(MAXN);
for (int j = 0; j <= k; j++) {
for(int a = 0; a <= m; a++){
if (a > j) {
break;
}
if (curs[i] + a > m) {
break;
}
int val = vals[curs[i] + a];
temp[j] = max(dp[j - a] + val, temp[j]);
}
}
dp = temp;
}
cout << dp[k] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |