답안 #125866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125866 2019-07-06T13:18:21 Z OptxPrime Sličice (COCI19_slicice) C++11
90 / 90
73 ms 1404 KB
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

 int n,m,k;
            int a[510];
            int b[510];
            int dp[510][510];
            int val[510];

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);


            cin>>n>>m>>k;
            for( int i=1;i<=n;i++ ){
                cin>>a[i];
            }
            for( int i=0;i<=m;i++ ) cin>>val[i];
            for( int i=0;i<=m;i++ ) dp[0][i] = 0;
            for( int i=1;i<=n;i++ ){
                for( int j=0;j<=k;j++ ){
                    for( int p=0;p<=j;p++ ){
                        //    if( j-p < 0 ) break;
                        dp[i][j] = max( dp[i][j], dp[i-1][j-p] + val[ a[i] + p ] );
                    }
                }
            }
        cout <<dp[n][k]<<endl;
        return 0;
    }

























# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1404 KB Output is correct
2 Correct 4 ms 1400 KB Output is correct
3 Correct 72 ms 1272 KB Output is correct
4 Correct 71 ms 1400 KB Output is correct
5 Correct 72 ms 1268 KB Output is correct
6 Correct 72 ms 1352 KB Output is correct
7 Correct 69 ms 1272 KB Output is correct
8 Correct 70 ms 1272 KB Output is correct
9 Correct 69 ms 1272 KB Output is correct
10 Correct 73 ms 1384 KB Output is correct