답안 #100348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100348 2019-03-10T13:25:19 Z pzdba Sličice (COCI19_slicice) C++14
90 / 90
121 ms 1400 KB
#include <bits/stdc++.h>
using namespace std;
int dp[501][501];
int p[501], b[501];
int main(){
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for(int i=1;i<=n;i++) scanf("%d", &p[i]);
    for(int i=0;i<=m;i++) scanf("%d", &b[i]);
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            for(int r=0;r<=m-p[i];r++){
                if(j+r <= k) dp[i][j+r] = max(dp[i][j+r], dp[i-1][j] + b[p[i]+r]);
                ans = max(ans, dp[i][j+r]);
            }
        }
    }
    printf("%d\n", ans);
}

Compilation message

slicice.cpp: In function 'int main()':
slicice.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
slicice.cpp:8:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%d", &p[i]);
                           ~~~~~^~~~~~~~~~~~~
slicice.cpp:9:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<=m;i++) scanf("%d", &b[i]);
                           ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1280 KB Output is correct
2 Correct 4 ms 1280 KB Output is correct
3 Correct 121 ms 1272 KB Output is correct
4 Correct 85 ms 1272 KB Output is correct
5 Correct 86 ms 1400 KB Output is correct
6 Correct 83 ms 1256 KB Output is correct
7 Correct 97 ms 1244 KB Output is correct
8 Correct 90 ms 1284 KB Output is correct
9 Correct 74 ms 1288 KB Output is correct
10 Correct 77 ms 1272 KB Output is correct