Submission #459649

#TimeUsernameProblemLanguageResultExecution timeMemory
459649OzyKitchen (BOI19_kitchen)C++17
100 / 100
38 ms1600 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define MAX 300 #define MAX2 90000 #define p first #define usa second pair<lli,lli> total[MAX2]; lli n,m,k,a,sum,sc; bool res; lli arr[MAX+2]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k; res = true; rep(i,1,n) { cin >> a; if (a < k) res = false; sum += a; } rep(i,1,m) {cin >> arr[i]; sc+=arr[i];} if (!res || sc < sum || m < k) {cout << "Impossible"; return 0;} total[0].p = 1; rep(i,1,m) { a = arr[i]; repa(j,sc,0) { if (total[j].p == 1) { total[j+a].p = 1; total[j+a].usa = max(total[j+a].usa, (min(n,a) + total[j].usa)); } } } a = k*n; rep(i,sum,sc) { if (total[i].p == 0) continue; if (total[i].usa >= a) { cout << (i-sum); 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...