Submission #161846

#TimeUsernameProblemLanguageResultExecution timeMemory
161846karmaKitchen (BOI19_kitchen)C++14
100 / 100
240 ms113784 KiB
#include <bits/stdc++.h> #define pb emplace_back #define ll long long #define fi first #define se second #define mp make_pair using namespace std; const int N = 307; const int Sum = N * N; int f[Sum][N], s, a[N], b[N], sum, n, m, k; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define Task "test" if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> m >> k; for(int i = 1; i <= n; ++i) { cin >> a[i], s += a[i]; if(a[i] < k) return cout << "Impossible", 0; } for(int j = 1; j <= m; ++j) cin >> b[j], sum += b[j]; memset(&f, -1, sizeof f); for(int i = 0; i <= m; ++i) f[0][i] = 0; for(int i = 1; i <= sum; ++i) { for(int j = 1; j <= m; ++j) { if(i - b[j] >= 0 && f[i - b[j]][j - 1] != -1) f[i][j] = f[i - b[j]][j - 1] + min(n, b[j]); } for(int j = 1; j <= m; ++j) f[i][j] = max(f[i][j - 1], f[i][j]); } for(int i = s; i <= sum; ++i) { if(f[i][m] >= k * n) return cout << i - s, 0; } cout << "Impossible"; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...