# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
567087 | 2022-05-23T07:56:15 Z | birthdaycake | Kitchen (BOI19_kitchen) | C++17 | 1 ms | 340 KB |
#include<bits/stdc++.h> #define endl '\n' #define int long long #define mod 1000000007 #define boost ios_base::sync_with_stdio(false), cin.tie(NULL); using namespace std; int a[200001],b[200001]; signed main(){ boost; int n,m,k, tot = 0, hours = 0; cin >> n >> m >> k; priority_queue<pair<int,int>>x; for(int i = 0; i < n; i++) cin >> a[i]; for(int j = 0; j < m; j++){ cin >> b[j]; x.push({b[j],j}); } for(int i = 0; i < n; i++){ vector<pair<int,int>>used; set<int>track; while(!x.empty() && track.size() < k && a[i] > 0){ auto y = x.top(); x.pop(); if(y.first){ b[y.second]--; a[i]--; if(b[y.second]) used.push_back({b[y.second],y.second}); track.insert(y.second); }else{ cout << "Impossible"; return 0; } } if(track.size() < k){ cout << "Impossible"; return 0; } for(int j = 0; j < used.size(); j++){ x.push({used[j].first,used[j].second}); } tot += a[i]; } priority_queue<int>s; while(!x.empty()){ hours += x.top().first; x.pop(); } if(hours - tot < 0) cout << "Impossible"; else cout << hours - tot; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |