제출 #300085

#제출 시각아이디문제언어결과실행 시간메모리
300085BeanZKitchen (BOI19_kitchen)C++14
100 / 100
40 ms1656 KiB
// I_LOVE_LPL
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e6 + 5;
const int lim = 3e2;
ll dp[N], is[N], a[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("A.inp", "r")){
                freopen("test.inp", "r", stdin);
                freopen("test.out", "w", stdout);
        }
        ll n, m, k;
        cin >> n >> m >> k;
        ll sum = 0;
        for (int i = 1; i <= n; i++){
                cin >> a[i];
                if (a[i] < k) return cout << "Impossible", 0;
                sum = sum + a[i];
        }
        is[0] = 1;
        for (int i = 1; i <= m; i++){
                ll a;
                cin >> a;
                for (int j = lim * lim; j >= a; j--){
                        if (is[j - a]){
                                ll cost = min(a, n);
                                is[j] = 1;
                                if (dp[j] < (dp[j - a] + cost)){
                                        dp[j] = dp[j - a] + cost;
                                }
                        }
                }
        }
        for (int i = sum; i <= (lim * lim); i++){
                if (dp[i] >= (n * k)){
                        cout << i - sum;
                        return 0;
                }
        }
        cout << "Impossible";
}
/*
*/

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

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