답안 #762182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762182 2023-06-21T03:36:43 Z anha3k25cvp Kitchen (BOI19_kitchen) C++14
21 / 100
29 ms 468 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>

using namespace std;

const int N = 5 + 1e5;
const int inf = 7 + 1e9;

vector <int> a, f;

int main() {
#define TASKNAME ""
    ios_base :: sync_with_stdio (0);
    cin.tie (0);
    if ( fopen( TASKNAME".inp", "r" ) ) {
        freopen (TASKNAME".inp", "r", stdin);
        freopen (TASKNAME".out", "w", stdout);
    }
    int n, m, k;
    cin >> n >> m >> k;
    int val = 0;
    for (int i = 1; i <= n; i ++) {
        int x;
        cin >> x;
        if (x < k) {
            cout << "Impossible";
            return 0;
        }
        val += x;
    }
    int ma = 0;
    a.assign(m + 1, 0);
    for (int i = 1; i <= m; i ++) {
        cin >> a[i];
        ma += a[i];
    }
    f.assign(ma + 1, 0);
    int ans = inf;
    for (int num = 0; num <= m; num ++)
        for (int sum = ma; sum >= 0; sum --) {
            if (num < m && sum + a[num + 1] <= ma)
                f[sum + a[num + 1]] = max(f[sum + a[num + 1]], f[sum] + min(a[num + 1], n));
            if (sum >= val && f[sum] >= n * k)
                ans = min(ans, sum);
        }
    if (ans < inf)
        cout << ans - val;
    else
        cout << "Impossible";
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:21:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen (TASKNAME".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:22:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen (TASKNAME".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 320 KB Output isn't correct
3 Halted 0 ms 0 KB -