# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101201 | mayhoubsaleh | Sličice (COCI19_slicice) | C++14 | 234 ms | 1656 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m,k;
int a[555],b[555];
int dp[555][555];
int solve(int i,int k){
if(i==n)return 0;
int &ans=dp[i][k];
if(ans!=-1)return ans;
for(int j=0;j<=k&&j+a[i]<=m;j++){
ans=max(ans,b[a[i]+j]+solve(i+1,k-j));
}
return ans;
}
int main(){
cin>>n>>m>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<=m;i++){
cin>>b[i];
}
memset(dp,-1,sizeof dp);
cout<<solve(0,k);
return 0;
}
//ofstream fout("planting.out");
//ifstream fin("planting.in");
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |