답안 #100267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100267 2019-03-10T07:16:02 Z ami Sličice (COCI19_slicice) C++14
90 / 90
53 ms 1528 KB
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const INF=1e9;
int const MAXN=550;
int N,M,K;
int P[MAXN];
int B[MAXN];
int f[MAXN][MAXN];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>M>>K;
	rep(i,0,N) cin>>P[i];
	rep(i,0,M+1) cin>>B[i];

	rep(i,0,N+1) rep(j,0,K+1) f[i][j]=-INF;
	f[0][0]=0;
	rep(i,0,N) rep(j,0,K+1) rep(k,0,min(M-P[i]+1,K-j+1)) {
		f[i+1][j+k]=max(f[i+1][j+k],f[i][j]+B[P[i]+k]);
	}

	cout<<f[N][K]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Correct 44 ms 1408 KB Output is correct
4 Correct 46 ms 1380 KB Output is correct
5 Correct 53 ms 1408 KB Output is correct
6 Correct 53 ms 1408 KB Output is correct
7 Correct 43 ms 1408 KB Output is correct
8 Correct 46 ms 1452 KB Output is correct
9 Correct 39 ms 1408 KB Output is correct
10 Correct 41 ms 1528 KB Output is correct