# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102228 | IvanC | Sličice (COCI19_slicice) | C++17 | 149 ms | 1428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 502;
int dp[MAXN][MAXN], A[MAXN], V[MAXN], N, M, K;
int solve(int n,int k){
if(n == N + 1) return 0;
if(dp[n][k] != -1) return dp[n][k];
int best = 0;
for(int qtd = 0; qtd + A[n] <= M && qtd <= k;qtd++){
int cand = solve(n+1,k - qtd) + V[A[n] + qtd];
best = max(best, cand);
}
return dp[n][k] = best;
}
int main(){
memset(dp, -1, sizeof(dp));
cin >> N >> M >> K;
for(int i = 1;i<=N;i++){
cin >> A[i];
}
for(int i = 0;i<=M;i++){
cin >> V[i];
}
cout << solve(1, K) << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |