Submission #299865

# Submission time Handle Problem Language Result Execution time Memory
299865 2020-09-15T22:12:30 Z ly20 Kitchen (BOI19_kitchen) C++17
0 / 100
4 ms 512 KB
#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(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);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -