Submission #377319

#TimeUsernameProblemLanguageResultExecution timeMemory
377319hhh07Kitchen (BOI19_kitchen)C++14
100 / 100
28 ms1024 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <map> #include <climits> #include <vector> #include <queue> #include <utility> #include <iomanip> #include <cstring> #include <fstream> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, m, k; cin >> n >> m >> k; ll a[n], b[m]; ll sum = 0; for (ll i = 0; i < n; i++){ cin >> a[i]; sum += a[i]; if (a[i] < k){ cout << "Impossible"; return 0; } } for (ll i = 0; i < m; i++) cin >> b[i]; if (k > m){ cout << "Impossible"; return 0; } vector<ll> dp(90001, (ll)-1e6); dp[0] = 0; for (ll i = 0; i < m; i++){ for (ll j = 90000 - b[i]; j >= 0 ; j--){ dp[j + b[i]] = max(dp[j + b[i]], dp[j] + min(n, b[i])); } } for (ll i = sum; i < 90001; i++){ if (dp[i] >= n*k){ cout << i - sum << endl; return 0; } } cout << "Impossible"; return 0; }
#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...