# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528364 | CSQ31 | Akcija (COCI21_akcija) | C++17 | 4 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |