Submission #1124385

#TimeUsernameProblemLanguageResultExecution timeMemory
1124385whoknowKitchen (BOI19_kitchen)C++20
100 / 100
17 ms708 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define MAXN 305 #define MAXSUM 90005 #define ii pair<int,int> #define bit(i,j) ((i>>j)&1) #define sz(i) (int)i.size() #define endl '\n' using namespace std; int n, m, K; int a[MAXN], b[MAXN]; namespace sub1 { int sum; int dp[MAXSUM]; void solve() { for(int i = 1; i <= n; i++) { if(a[i] < K) return cout << "Impossible", void(); sum += a[i]; } memset(dp, -0x3f, sizeof(dp)); dp[0] = 0; for(int i = 1; i <= m; i++) for(int j = MAXSUM - 5; j >= b[i]; j--) dp[j] = max(dp[j], dp[j - b[i]] + min(b[i], n)); for(int i = sum; i <= MAXSUM - 5; i++) if(dp[i] >= n * K) return cout << i - sum, void(); cout << "Impossible"; } } main() { if(fopen("TEST.inp", "r")) { freopen("TEST.inp", "r", stdin); freopen("TEST.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> K; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; if(K > m) return cout << "Impossible", 0; sub1::solve(); } /** 2 4 3 5 5 1 4 5 1 **/

Compilation message (stderr)

kitchen.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main()
      | ^~~~
kitchen.cpp: In function 'int main()':
kitchen.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen("TEST.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen("TEST.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...