답안 #146469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146469 2019-08-24T08:36:21 Z Alexa2001 Kitchen (BOI19_kitchen) C++17
21 / 100
22 ms 760 KB
#include <bits/stdc++.h>

using namespace std;

const int lim = 300;

int dp[lim * lim + 10];
int n, m, k;
int A[lim+2], B[lim+2];


void add(int cost, int ben)
{
    int i;
    for(i=m*lim - cost; i>=0; --i)
        dp[i+cost] = max(dp[i+cost], dp[i] + ben);
}

int main()
{
  //  freopen("kitchen2.in", "r", stdin);
    cin.tie(0); cin.sync_with_stdio(false);

    cin >> n >> m >> k;
    
    int i, sum = 0;
    
    for(i=1; i<=n; ++i) cin >> A[i], sum += A[i];
    for(i=1; i<=m; ++i) cin >> B[i];
    
    for(i=1; i<=m; ++i)
        add(B[i], min(n, B[i]));
    
    for(i=1; i<=n; ++i)
        if(A[i] < k) 
        {
            cout << "Impossible\n";
            return 0;
        }

    for(i=sum; i <= m*lim; ++i)
        if(dp[i] >= k * n)
        {
            cout << i - sum << '\n';
            return 0;
        }
    cout << "Impossible\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -