Submission #747728

#TimeUsernameProblemLanguageResultExecution timeMemory
747728nguyentunglamKitchen (BOI19_kitchen)C++17
31 / 100
2 ms324 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 310; int b[N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, m, k; cin >> n >> m >> k; int sum = 0, ans = 1e9; for(int i = 1; i <= n; i++) { int x; cin >> x; if (x < k) return cout << "Impossible", 0; sum += x; } for(int i = 0; i < m; i++) cin >> b[i]; for(int mask = 0; mask < (1 << m); mask++) { int sum1 = 0, sum2 = 0; for(int i = 0; i < m; i++) if (mask >> i & 1) { sum1 += min(n, b[i]); sum2 += b[i]; } if (sum1 >= n * k && sum2 >= sum) ans = min(ans, sum2 - sum); } if (ans == 1e9) return cout << "Impossible", 0; cout << ans; }

Compilation message (stderr)

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