# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
303025 | bigg | Kitchen (BOI19_kitchen) | C++14 | 15 ms | 640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXV = 1e5 + 10;
int dp[MAXV];
int a[310], b[310];
int n, m, k;
int main(){
scanf("%d %d %d", &n, &m, &k);
int soma = 0, mina = 1e9 + 7;
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
mina = min(mina, a[i]);
soma += a[i];
}
for(int i = 1; i <= m; i++) scanf("%d", &b[i]);
if(mina < k){
printf("Impossible\n");
return 0;
}
if(k == 1){
dp[0] = 1;
for(int i = 1; i <= m; i++){
for(int j = 90000 - b[i]; j >= 0; j--){
dp[j + b[i]] |= dp[j];
}
}
for(int i = soma; i <= 90000; i++){
if(dp[i]){
printf("%d\n", i -soma);
return 0;
}
}
printf("Impossible\n");
}
else{
int ans = 1e9 + 7;
for(int i = 0; i <(1<<m); i++){
if(__builtin_popcount(i) < k) continue;
int lsoma = 0;
int chefmin = n*k;
int cheftot = 0;
for(int j = 1; j <= m; j++){
if((1<<(j-1))&i) lsoma += b[j],cheftot += min(n,b[j]);
}
if(cheftot >= chefmin && lsoma >= soma){
ans = min(lsoma - soma, ans);
}
}
if(ans == 1e9 + 7){
printf("Impossible\n");
return 0;
}
printf("%d\n", ans);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |