Submission #921100

#TimeUsernameProblemLanguageResultExecution timeMemory
921100shoryu386Kitchen (BOI19_kitchen)C++17
30 / 100
277 ms249364 KiB
#include <bits/stdc++.h> using namespace std; #define int long long main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; int buckets[n], balls[m]; for (int x = 0; x < n; x++) cin >> buckets[x]; for (int x = 0; x < m; x++) cin >> balls[x]; #define IMP cout << "Impossible"; return 0; bool dead = false; for (int x = 0; x < n; x++){ if (buckets[x] < k){ dead = true; } } if (dead) {IMP;} int bucketsum = 0; for (int x = 0; x < n; x++){ bucketsum += buckets[x]; } #define BSMAX 1607 bool hmm[m+1][BSMAX][n*k+1]; memset(hmm, 0, sizeof(hmm)); hmm[0][0][n*k] = 1; for (int x = 0; x < m; x++){ for (int y = 0; y < BSMAX; y++){ for (int z = 0; z <= n*k; z++){ if (!hmm[x][y][z]) continue; hmm[x+1][y + balls[x]][max(0LL, z - min(balls[x], n))] = 1; hmm[x+1][y][z] = 1; } } } int ans = -1; for (int x = bucketsum; x < BSMAX; x++){ if (hmm[m][x][0]){ ans = x-bucketsum; break; } } if (ans == -1) cout << "Impossible"; else cout << ans; }

Compilation message (stderr)

kitchen.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...