Submission #524449

#TimeUsernameProblemLanguageResultExecution timeMemory
524449Jarif_RahmanKitchen (BOI19_kitchen)C++17
21 / 100
105 ms68484 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> A(n), B(m); int s1 = 0, s2 = 0; for(int &x: A){ cin >> x, s1+=x; if(x < k){ cout << "Impossible\n"; exit(0); } } for(int &x: B) cin >> x, s2+=x; vector<vector<int>> dp(m, vector<int>(s2+1, -1e9)); for(int i = 0; i < m; i++) dp[i][0] = 0; for(int i = m-1; i >= 0; i--) for(int j = s2; j >= 0; j--){ if(i != m-1) dp[i][j] = dp[i+1][j]; if(j-B[i] >= 0){ dp[i][j] = max(dp[i][j], (i != m-1 ? dp[i+1][j-B[i]]:0)+min(B[i], n)); } } for(int i = s1; i <= s2; i++){ if(dp[0][i] >= n*k){ cout << i-s1 << "\n"; exit(0); } } cout << "Impossible\n"; }
#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...