#include <bits/stdc++.h>
using namespace std;
#define task "task"
#define bit(x, i) ((x >> i) & 1)
// https://trap.jp/post/1224/
#define FOR1(i, a, b) for(int i = (a), _b = (b); i <= _b; i ++)
#define FOR2(i, a, b, c) for(int i = (a), _b = (b); i <= _b; i += c)
#define FORD1(i, a, b) for(int i = (a), _b = (b); i >= _b; i --)
#define FORD2(i, a, b, c) for(int i = (a), _b = (b); i >= _b; i -= c)
#define overload4(a, b, c, d, name, ...) name
#define FOR(...) overload4(__VA_ARGS__, FOR2, FOR1)(__VA_ARGS__)
#define FORD(...) overload4(__VA_ARGS__, FORD2, FORD1)(__VA_ARGS__)
#define pb emplace_back
#define pf emplace_front
#define ins emplace
#define mp make_pair
#define fi first
#define se second
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
// mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
// ll rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); }
const int N = 505;
const ll inf = 1e18;
const int mod = 1e9 + 7;
const int base = 31;
int n, m, k, p[N], b[N], dp[N][N];
/*
dp[i][j] duyệt đến thằng i và đã chọn thêm j thẻ đạt điểm tối đa
dp[i][j] = dp[i - 1][i - t] + b[p[i] + t]
*/
void solve(){
cin>>n>>m>>k;
FOR(i, 1, n) cin>>p[i];
FOR(i, 0, m) cin>>b[i];
FOR(i, 1, n)
FOR(j, 0, k){
dp[i][j] = dp[i - 1][j];
FOR(t, 0, min(j, m - p[i])) dp[i][j] = max(dp[i][j], dp[i - 1][j - t] + b[p[i] + t]);
}
cout<<dp[n][k];
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
if(fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int nTest = 1;
// cin>>nTest;
while(nTest --) solve();
cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
slicice.cpp: In function 'int main()':
slicice.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
slicice.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |