# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
528365 |
2022-02-20T07:37:02 Z |
CSQ31 |
Akcija (COCI21_akcija) |
C++17 |
|
5 ms |
588 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Incorrect |
3 ms |
204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
460 KB |
Output is correct |
2 |
Correct |
4 ms |
460 KB |
Output is correct |
3 |
Correct |
4 ms |
588 KB |
Output is correct |
4 |
Correct |
4 ms |
588 KB |
Output is correct |
5 |
Correct |
5 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Incorrect |
3 ms |
204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |