제출 #1130153

#제출 시각아이디문제언어결과실행 시간메모리
1130153vladiliusKitchen (BOI19_kitchen)C++20
31 / 100
2 ms328 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin>>n>>m>>k; vector<int> a(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; } vector<int> b(m); for (int i = 0; i < m; i++){ cin>>b[i]; } int S1 = 0; for (int i = 1; i <= n; i++){ if (a[i] < k){ cout<<"Impossible"<<"\n"; return 0; } S1 += a[i]; } int S2 = k * n, out = 1e9; for (int i = 1; i < (1 << m); i++){ int s1 = 0, s2 = 0; for (int j = 0; j < m; j++){ if ((i >> j) & 1){ s1 += b[j]; s2 += min(n, b[j]); } } if (s1 >= S1 && s2 >= S2){ out = min(out, s1); } } if (out == 1e9){ cout<<"Impossible"<<"\n"; } else { cout<<out - S1<<"\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...