Submission #567080

#TimeUsernameProblemLanguageResultExecution timeMemory
567080birthdaycakeKitchen (BOI19_kitchen)C++17
0 / 100
1 ms340 KiB
#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, ans = 1e18, 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>rep,s; while(!x.empty()){ hours += x.top().first; rep.push(x.top().first); x.pop(); } /*s = rep; int rst = tot; int l = 0, r = 300; while(l <= r){ int mid = (l + r) / 2, bad = 0; while(tot > 0 && !s.empty()){ } }*/ if(hours - tot < 0) cout << "Impossible"; else cout << hours - tot; return 0; }

Compilation message (stderr)

kitchen.cpp:61:5: warning: "/*" within comment [-Wcomment]
   61 |     /*s = rep;
      |      
kitchen.cpp: In function 'int main()':
kitchen.cpp:33:42: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   33 |         while(!x.empty() && track.size() < k && a[i] > 0){
      |                             ~~~~~~~~~~~~~^~~
kitchen.cpp:46:25: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |         if(track.size() < k){
      |            ~~~~~~~~~~~~~^~~
kitchen.cpp:50:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int j = 0; j < used.size(); j++){
      |                        ~~^~~~~~~~~~~~~
kitchen.cpp:19:25: warning: unused variable 'ans' [-Wunused-variable]
   19 |     int n,m,k, tot = 0, ans = 1e18, hours = 0; cin >> n >> m >> k;
      |                         ^~~
#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...