답안 #524456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524456 2022-02-09T08:48:24 Z Jarif_Rahman Kitchen (BOI19_kitchen) C++17
100 / 100
95 ms 100352 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k; cin >> n >> m >> k;

    vector<int> A(n), B(m);
    int s1 = 0, s2 = 0;
    for(int &x: A){
        cin >> x, s1+=x;
        if(x < k){
            cout << "Impossible\n";
            exit(0);
        }
    }
    for(int &x: B) cin >> x, s2+=x;

    vector<vector<int>> dp(m, vector<int>(s2+1, -1e9));
    for(int i = 0; i < m; i++) dp[i][0] = 0;
    dp[m-1][B[m-1]] = min(B[m-1], n);
    
    for(int i = m-2; i >= 0; i--) for(int j = s2; j >= 0; j--){
        dp[i][j] = dp[i+1][j];
        if(j-B[i] >= 0){
            dp[i][j] = max(dp[i][j], dp[i+1][j-B[i]] + min(B[i], n));
        }
    }

    for(int i = s1; i <= s2; i++){
        if(dp[0][i] >= n*k){
            cout << i-s1 << "\n";
            exit(0);
        }
    }

    cout << "Impossible\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 444 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 68500 KB Output is correct
2 Correct 55 ms 51140 KB Output is correct
3 Correct 47 ms 56996 KB Output is correct
4 Correct 95 ms 97932 KB Output is correct
5 Correct 88 ms 98156 KB Output is correct
6 Correct 35 ms 41292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 444 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 60 ms 68500 KB Output is correct
15 Correct 55 ms 51140 KB Output is correct
16 Correct 47 ms 56996 KB Output is correct
17 Correct 95 ms 97932 KB Output is correct
18 Correct 88 ms 98156 KB Output is correct
19 Correct 35 ms 41292 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 42 ms 50100 KB Output is correct
26 Correct 52 ms 61888 KB Output is correct
27 Correct 16 ms 18252 KB Output is correct
28 Correct 42 ms 51240 KB Output is correct
29 Correct 57 ms 69632 KB Output is correct
30 Correct 86 ms 100352 KB Output is correct