Submission #567489

#TimeUsernameProblemLanguageResultExecution timeMemory
567489RifalKitchen (BOI19_kitchen)C++14
100 / 100
49 ms1636 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 1668223877717 #define INF -100000000000000000 //#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; int n, m, k; pair<bool,long long> dp[M] = {}; void add(int x) { for(int i = M-1; i >= x; i--) { if(dp[i-x].first == 1) { dp[i].first = 1; dp[i].second = max(dp[i].second,dp[i-x].second+min(n,x)); } } } int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); cin >> n >> m >> k; int meal[n], chef[m]; long long sum = 0; bool ok = true; dp[0].first = 1; for(int i = 0; i < n; i++) { cin >> meal[i]; if(meal[i] < k) ok = false; sum += meal[i]; } for(int i = 0; i < m; i++) { cin >> chef[i]; add(chef[i]); } if(ok == false) { cout << "Impossible"; return 0; } for(int i = sum; i < M; i++) { if(dp[i].second >= n*k) { 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...