Submission #528364

#TimeUsernameProblemLanguageResultExecution timeMemory
528364CSQ31Akcija (COCI21_akcija)C++17
10 / 110
4 ms640 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { int n,k; cin>>n>>k; vector<array<int,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]-1 >= -x.first)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((int)(s.size()) > k){ auto it = s.end(); it--; s.erase(it); } } if(s.size()<k)s.insert({0,0}); for(auto x:s)cout<<-x.first<<" "<<x.second<<'\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:25:13: warning: comparison of integer expressions of different signedness: 'std::multiset<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |  if(s.size()<k)s.insert({0,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...
#Verdict Execution timeMemoryGrader output
Fetching results...