Submission #528365

#TimeUsernameProblemLanguageResultExecution timeMemory
528365CSQ31Akcija (COCI21_akcija)C++17
10 / 110
5 ms588 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define sz(a) (int)(a.size()) int main() { int n,k; cin>>n>>k; vector<array<ll,2>>v(n); for(int i=0;i<n;i++)cin>>v[i][1]>>v[i][0]; sort(v.begin(),v.end()); multiset<pair<ll,ll>>s; for(int i=0;i<n;i++){ vector<pair<ll,ll>>tmp; for(auto x:s){ if(v[i][0] >= -x.first + 1)tmp.push_back({x.first-1,x.second + v[i][1]}); } tmp.push_back({-1,v[i][1]}); for(auto x:tmp)s.insert(x); while(sz(s) > k){ auto it = s.end(); it--; s.erase(it); } } if(sz(s)<k)s.insert({0,0}); for(auto x:s)cout<<-x.first<<" "<<x.second<<'\n'; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...