답안 #299868

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299868 2020-09-15T22:33:33 Z ly20 Kitchen (BOI19_kitchen) C++17
100 / 100
57 ms 796 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
bool dp[MAXN * MAXN];
int sm[MAXN * 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(n, 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;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d %d %d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         scanf("%d", &a); ms += a;
      |         ~~~~~^~~~~~~~~~
kitchen.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 632 KB Output is correct
2 Correct 34 ms 640 KB Output is correct
3 Correct 48 ms 504 KB Output is correct
4 Correct 46 ms 796 KB Output is correct
5 Correct 57 ms 760 KB Output is correct
6 Correct 32 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 40 ms 632 KB Output is correct
15 Correct 34 ms 640 KB Output is correct
16 Correct 48 ms 504 KB Output is correct
17 Correct 46 ms 796 KB Output is correct
18 Correct 57 ms 760 KB Output is correct
19 Correct 32 ms 512 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 256 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 32 ms 632 KB Output is correct
26 Correct 37 ms 624 KB Output is correct
27 Correct 24 ms 508 KB Output is correct
28 Correct 37 ms 512 KB Output is correct
29 Correct 40 ms 640 KB Output is correct
30 Correct 46 ms 760 KB Output is correct