답안 #464470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464470 2021-08-13T09:24:06 Z osmanallazov Kitchen (BOI19_kitchen) C++14
20 / 100
19 ms 372 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=300;
int a[MAXN+1],b[MAXN+1];
bool dp[MAXN*MAXN+1];
int main() {
    int i,n,m,k;
    cin>>n>>m>>k;
    int sum=0,suma=0;
    for(i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i]-(k-1);
        suma+=a[i];
    }
    if(*min_element(a+1,a+n+1)<k){
        cout<<"Impossible";
        return 0;
    }
    int sumb=0;
    for(i=1;i<=m;i++){
        cin>>b[i];
        sumb+=b[i];
    }
    sort(b+1,b+m+1);
    sum=min(sum,b[m]);
    dp[0]=i=1;
    while(i<=m && b[i]<=sum){
        for(int j=sumb;j>=b[i];j--) {
            dp[j]|=dp[j-b[i]];
        }
        i++;
    }
    i=suma;
    while(i<=sumb && dp[i]==0){
        i++;
    }
    if(i>sumb){
        cout<<"Impossible";
        return 0;
    }
    cout<<i-suma;
    return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:27:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   27 |     dp[0]=i=1;
      |           ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 332 KB Output is correct
2 Correct 10 ms 356 KB Output is correct
3 Correct 11 ms 344 KB Output is correct
4 Correct 18 ms 372 KB Output is correct
5 Correct 19 ms 332 KB Output is correct
6 Correct 8 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -