답안 #524449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524449 2022-02-09T08:42:43 Z Jarif_Rahman Kitchen (BOI19_kitchen) C++17
21 / 100
105 ms 68484 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;
    
    for(int i = m-1; i >= 0; i--) for(int j = s2; j >= 0; j--){
        if(i != m-1) dp[i][j] = dp[i+1][j];
        if(j-B[i] >= 0){
            dp[i][j] = max(dp[i][j], (i != m-1 ? dp[i+1][j-B[i]]:0)+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 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 105 ms 68484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 444 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -