제출 #314120

#제출 시각아이디문제언어결과실행 시간메모리
314120phathnvSličice (COCI19_slicice)C++11
90 / 90
66 ms384 KiB
#include <bits/stdc++.h>

#define mp make_pair
#define X first
#define Y second
#define taskname "SLCICE"

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 501;

int n, m, k, p[N], b[N], dp[2][N];

void readInput(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    for(int i = 0; i <= m; i++)
        cin >> b[i];
}

void solve(){
    for(int i = 1; i <= n; i++){
        int id = i & 1;
        for(int j = p[i]; j <= m; j++)
            for(int c = 0; c <= k; c++){
                if (c + j - p[i] > k)
                    break;
                dp[id][c + j - p[i]] = max(dp[id][c + j - p[i]], dp[id ^ 1][c] + b[j]);
            }
    }
    cout << dp[n & 1][k];
}

int main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    readInput();
    solve();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

slicice.cpp: In function 'int main()':
slicice.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   40 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
slicice.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...