Submission #314457

#TimeUsernameProblemLanguageResultExecution timeMemory
314457shrek12357Sličice (COCI19_slicice)C++14
90 / 90
159 ms384 KiB
#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 timeMemoryGrader output
Fetching results...