Submission #567166

#TimeUsernameProblemLanguageResultExecution timeMemory
567166RealSnakeKitchen (BOI19_kitchen)C++14
0 / 100
459 ms33312 KiB
#include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<pair<int, int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define ll long long #define mod 1000000007 ofstream fout(".out"); ifstream fin(".in"); int dp[90001]; vector<int> v[90001]; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, k; cin >> n >> m >> k; int a[n], b[m]; int x = 0; bool bad = 0; for(int i = 0; i < n; i++) { cin >> a[i]; x += a[i]; if(a[i] < k) bad = 1; } int sum = 0; for(int i = 0; i < m; i++) { cin >> b[i]; sum += b[i]; } if(bad) { cout << "Impossible"; return 0; } for(int i = 0; i < m; i++) { for(int j = sum; j >= b[i]; j--) { if(j == b[i] || v[j - b[i]].size()) { int y = 0; for(int o : v[j - b[i]]) y += (o > 0); if(j == b[i] || y > dp[j]) { dp[j] = y + 1; v[j] = v[j - b[i]]; int sz = v[j].size(); for(int o = 0; o < sz; o++) { if(v[j][o]) v[j][o]--; } v[j].push_back(b[i] - 1); } } } } for(int i = x; i <= sum; i++) { cout << i << " " << dp[i] << "\n"; if(dp[i] >= k) { cout << i - x; 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...