Submission #525536

#TimeUsernameProblemLanguageResultExecution timeMemory
525536Yazan_AlattarKitchen (BOI19_kitchen)C++14
0 / 100
1094 ms460 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 307; const int N = 20; const ll inf = 1e18; const ll mod = 998244353; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int n, m, k, sum, a[M], b[M]; bool dp[M * N][N * N]; int main() { scanf("%d%d%d", &n, &m, &k); if(k > m) printf("Impossible\n"), exit(0); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum += a[i]; if(a[i] < k) printf("Impossible\n"), exit(0); } for(int i = 1; i <= m; ++i) scanf("%d", &b[i]); dp[0][0] = 1; for(int i = 1; i <= m; ++i) { for(int cost = M * N - b[i] - 1; cost >= 0; --cost) { for(int filled = 0; filled + min(n, b[i]) < N * N; ++filled) { dp[filled + min(n, b[i])][cost + b[i]] |= dp[filled][cost]; } } for(int cost = M * N - b[i] - 1; cost >= 0; --cost) for(int filled = N * N - 2; filled >= 0; --filled) dp[filled][cost] |= dp[filled + 1][cost]; } for(int i = sum; i < M * N; ++i) if(dp[n * k][i]) printf("%d\n", i - sum), exit(0); printf("Impossible\n"); return 0; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d",  &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~
kitchen.cpp:28:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  for(int i = 1; i <= m; ++i) scanf("%d", &b[i]);
      |                              ~~~~~^~~~~~~~~~~~~
#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...