# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
115068 |
2019-06-05T04:34:32 Z |
MB81 |
Sličice (COCI19_slicice) |
C++14 |
|
52 ms |
1528 KB |
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
// dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int maxn = 5e2+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;
int p[maxn], b[maxn];
int dp[maxn][maxn];
int n, m, k;
int main () {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 0; i <= m; i++)
cin >> b[i];
for (int i = 0; i < maxn; i++)
for (int t = 0; t < maxn; t++)
dp[i][t] = -IN;
dp[0][0] = 0;
for (int i = 1; i <= n; i++)
for (int t = 0; t <= k; t++)
for (int j = 0; j + t <= k && j + p[i] <= m; j++)
dp[i][j + t] = max(dp[i][j + t], dp[i - 1][t] + b[j + p[i]]);
cout << dp[n][k] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1408 KB |
Output is correct |
2 |
Correct |
3 ms |
1408 KB |
Output is correct |
3 |
Correct |
49 ms |
1528 KB |
Output is correct |
4 |
Correct |
49 ms |
1528 KB |
Output is correct |
5 |
Correct |
49 ms |
1408 KB |
Output is correct |
6 |
Correct |
49 ms |
1448 KB |
Output is correct |
7 |
Correct |
47 ms |
1408 KB |
Output is correct |
8 |
Correct |
52 ms |
1408 KB |
Output is correct |
9 |
Correct |
49 ms |
1408 KB |
Output is correct |
10 |
Correct |
52 ms |
1408 KB |
Output is correct |