Submission #1197958

#TimeUsernameProblemLanguageResultExecution timeMemory
1197958santi3223Kitchen (BOI19_kitchen)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vl vector<ll> #define pb push_back #define pll pair<ll, ll> #define vs vector<string> #define vb vector<bool> #define all(aaa) aaa.begin(), aaa.end() #define rall(aaa) aaa.rbegin(), aaa.rend() #define ff(aa, bb, cc) for(ll aa = bb; aa < cc; aa++) #define IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ed "\n" #define fi first #define se second ll MOD = 1e9+7; int main(){ ll n, m, k; cin >> n >> m >> k; vl arr(m); ll suma = 0; ff(i, 0, n){ ll x; cin >> x; suma += x; } ff(i, 0, m){ cin >> arr[i]; } map<ll, ll> mp; mp[0] = 1; ll minn = LLONG_MAX; ff(i, 0, n){ for(auto &p : mp){ ll x = p.se; mp[x+arr[i]] = 1; if(x+arr[i] >= suma){ minn = min(minn, x+arr[i]); } } } if(minn == LLONG_MAX){ cout << "Impossible"; } else{ cout << minn-suma; } 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...