# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
299863 | ly20 | Kitchen (BOI19_kitchen) | C++17 | 4 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
bool dp[MAXN * MAXN];
int sm[MAXN];
int n, m, k;
int main() {
bool ok = true;
scanf("%d %d %d", &n, &m, &k);
int ms = 0;
for(int i = 0; i < n; i++) {
int a;
scanf("%d", &a); ms += a;
if(a < k) ok = false;
}
//printf("%d\n", ms);
if(m < k) ok = false;
dp[0] = 1;
for(int i = 0; i < m; i++) {
int a;
scanf("%d", &a);
for(int j = MAXN * MAXN - 1; j >= a; j--) {
int p = min(k, a);
if(dp[j - a]) {
//printf("%d\n", j);
dp[j] = 1;
int t = p + sm[j - a];
sm[j] = max(t, sm[j]);
//printf("%d\n", sm[j]);
}
}
}
int ft = ms - 1;
for(int i = ms; i < MAXN * MAXN; i++) {
if(sm[i] >= n * k) {
//printf("%d\n", i);
ft = i;
break;
}
}
if(ft == ms - 1 || !ok) printf("Impossible\n");
else printf("%d\n", ft - ms);
return 0;
}
컴파일 시 표준 에러 (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... |