답안 #745865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745865 2023-05-21T08:53:15 Z vjudge1 Kitchen (BOI19_kitchen) C++17
20 / 100
138 ms 102092 KB
#include <bits/stdc++.h>
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using ll = long long;

const int maxN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;


int main() {

/*#ifndef ONLINE_JUDGE
   freopen("../../input.txt", "r", stdin);
   freopen("../../output.txt", "w", stdout);
#endif*/
   InTheNameOfGod;

    int n,m,k;
    cin >>n >> m >> k;

    vector<int> a(n),b(m);
    int s = 0, must = (n)*(k-1);
    bool ok = 0;
    for(int i = 0; i < n; i++)  {
        cin >> a[i];
        s += a[i];
        if(a[i] < k) ok = 1;
    }

    for(int &i : b) cin >> i;

    if(ok || m < k) {
        cout << "Impossible\n";
        return 0;
    }

    vector<vector<int> > dp(m+1, vector<int> (s+1, INF));
    int mo = INF;
    dp[0][0] = n*k;
    for(int i = 0; i < m; i++)  {
        for(int j = 0; j < s; j++) {
            if(dp[i][j] != INF) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                if(j + b[i] >= s && dp[i][j] - min(b[i], n) <= 0) mo = min(mo, j+b[i] - s);
                else dp[i+1][j+b[i]] = min(dp[i+1][j+b[i]], dp[i][j] - min(b[i], n));
            }

            //cout << i << ", " << j << ": " << dp[i][j] << endl;
        }
    }
    if(mo == INF) cout << "Impossible" << endl;
    else cout << mo;

    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:23:16: warning: unused variable 'must' [-Wunused-variable]
   23 |     int s = 0, must = (n)*(k-1);
      |                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 51984 KB Output is correct
2 Correct 45 ms 44996 KB Output is correct
3 Correct 74 ms 55892 KB Output is correct
4 Correct 138 ms 89796 KB Output is correct
5 Correct 121 ms 102092 KB Output is correct
6 Correct 40 ms 41572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 724 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -