답안 #771756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771756 2023-07-03T08:53:56 Z teo_thrash Kitchen (BOI19_kitchen) C++14
21 / 100
26 ms 12836 KB
#include<bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int maxn=1e6+3;
const int mod=1e9+7;

int n, m, k, a[320], b[320];

int dp[320][10003];
ll a_sum=0, b_sum=0;

int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

cin>>n>>m>>k;
for(int i=1; i<=n; i++){
    cin>>a[i];

    if(a[i]<k){
        cout<<"Impossible";
        return 0;
    }

    a_sum+=a[i];
}
for(int i=1; i<=m; i++){
    cin>>b[i];
    b_sum+=b[i];
}

memset(dp, -1, sizeof(dp));

dp[0][0]=0;

for(int i=1; i<=m; i++){

    for(int j=1; j<=b_sum; j++){
        dp[i][j]=dp[i-1][j];

        if(b[i]<=j){
            dp[i][j]=max(dp[i][j], dp[i-1][j-b[i]]+min(n, b[i]));
        }
    }
}

int ans=INT_MAX;
for(int j=a_sum; j<=b_sum; j++){
    if(dp[m][j]>=n*k){
        cout<<j-a_sum<<endl;
        return 0;
    }
}

cout<<"Impossible";

return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:54:5: warning: unused variable 'ans' [-Wunused-variable]
   54 | int ans=INT_MAX;
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 12756 KB Output is correct
2 Incorrect 5 ms 12756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 12756 KB Output is correct
2 Incorrect 5 ms 12756 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 12836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 12744 KB Output is correct
2 Correct 5 ms 12756 KB Output is correct
3 Correct 5 ms 12752 KB Output is correct
4 Correct 5 ms 12756 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 12756 KB Output is correct
2 Incorrect 5 ms 12756 KB Output isn't correct
3 Halted 0 ms 0 KB -