Submission #1224142

#TimeUsernameProblemLanguageResultExecution timeMemory
1224142sleepntsheepKitchen (BOI19_kitchen)C++17
Compilation error
0 ms0 KiB
#include <stdio.h> #include <bitset> #define N 405 int n, m, k, a[N], b[N], sum, ans = 1e9; std::bitset<N * N> dp[2][N * N]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]), sum += a[i]; if (a[i] < k) { puts("Impossible"); return 0; } } dp[0][0][0] = 1; for (int i = 1; i <= m; ++i) { scanf("%d", &b[i]); int x_ = b[i] < n ? b[i] : n, y_ = b[i]; for (int j = N * N - 1; j >= 0; --j) dp[i & 1][j] = dp[i & 1 ^ 1][j]; for (int j = N * N - 1; j >= x_; --j) dp[i & 1][j] |= dp[i & 1 ^ 1][j - x_] << y_; } for (int h = 0; h + sum < N * N; ++h) { for (int j = n * k; j < N * N; ++j) { if (dp[m][j][sum + h]) { printf("%d\n", h); return 0; } } } puts("Impossible"); return 0; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d%d%d", &n, &m, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:13:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |                 scanf("%d", &a[i]), sum += a[i];
      |                 ~~~~~^~~~~~~~~~~~~
kitchen.cpp:22:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 scanf("%d", &b[i]);
      |                 ~~~~~^~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libc.a(assert.o): in function `__assert_fail_base':
(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `__abort_msg' defined in .bss section in /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libc.a(abort.o)
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libc.a(loadmsgcat.o): in function `_nl_load_domain':
(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x5e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x39b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x3ab): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x3b6): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x3c0): relocation truncated to fit: R_X86_64_PC32 against `.bss'
(.text+0x3fb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status