Submission #567143

#TimeUsernameProblemLanguageResultExecution timeMemory
567143RifalKitchen (BOI19_kitchen)C++14
20 / 100
20 ms368 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 32768 #define INF 100000000000000 //#define ll long long //#define cin fin //#define cout fout using namespace std; //ofstream fout("convention.out"); //ifstream fin("convention.in"); const int M = 9e4 + 5; bool dp[M] = {}; void add(int x) { for(int i = M-1; i >= x; i--) { if(dp[i-x]) dp[i] = 1; } } int main() { int n, m, k; cin >> n >> m >> k; int meal[n], chef[m]; dp[0] = 1; long long sum = 0; for(int i = 0; i < n; i++) { cin >> meal[i]; sum += meal[i]; } for(int i = 0; i < m; i++) { cin >> chef[i]; add(chef[i]); } bool check = false; long long ans = 0; for(int i = sum; i < M; i++) { if(dp[i]) { check = true; ans = i-sum; break; } } if(check) cout << ans; else 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...