Submission #902618

# Submission time Handle Problem Language Result Execution time Memory
902618 2024-01-10T20:48:22 Z SalihSahin Akcija (COCI21_akcija) C++17
90 / 110
5000 ms 18756 KB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
 
const int mod = 1e9 + 7;
const int inf = 1e17*2;
const int N = 2e5 + 5;
 
int32_t main(){
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    multiset<int> best[n+2];
    best[0].insert(0);
    vector<pair<int, int> > a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i].second>>a[i].first;
    }
    sort(a.begin(), a.end());

    for(int i = 0; i < n; i++){
        for(int j = a[i].first-1; j >= 0; j--){
            for(auto itr: best[j]){
                best[j+1].insert(a[i].second + itr);
            }
            while(best[j+1].size() > k){
                auto k = best[j+1].end();
                k--;
                best[j+1].erase(k);
            }
        }
    }

    vector<pair<int, int> > ans;
    for(int i = n; i >= 0; i--){
        for(auto itr: best[i]){
            ans.pb(mp(i, itr));
        }
        if(ans.size() > k) break;
    }

    for(int i = 0; i < k; i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:29:36: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   29 |             while(best[j+1].size() > k){
      |                   ~~~~~~~~~~~~~~~~~^~~
Main.cpp:42:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   42 |         if(ans.size() > k) break;
      |            ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 49 ms 600 KB Output is correct
2 Correct 52 ms 668 KB Output is correct
3 Correct 46 ms 596 KB Output is correct
4 Correct 53 ms 668 KB Output is correct
5 Correct 52 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 15 ms 624 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 600 KB Output is correct
2 Correct 52 ms 668 KB Output is correct
3 Correct 46 ms 596 KB Output is correct
4 Correct 53 ms 668 KB Output is correct
5 Correct 52 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 15 ms 624 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 67 ms 604 KB Output is correct
15 Correct 57 ms 672 KB Output is correct
16 Correct 48 ms 612 KB Output is correct
17 Correct 57 ms 604 KB Output is correct
18 Correct 72 ms 652 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 13 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 145 ms 748 KB Output is correct
2 Correct 163 ms 696 KB Output is correct
3 Correct 133 ms 632 KB Output is correct
4 Correct 122 ms 716 KB Output is correct
5 Correct 145 ms 932 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 33 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1628 KB Output is correct
2 Correct 17 ms 1628 KB Output is correct
3 Correct 11 ms 1548 KB Output is correct
4 Correct 9 ms 1428 KB Output is correct
5 Correct 15 ms 1856 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 5 ms 860 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 10 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 872 KB Output is correct
2 Correct 30 ms 836 KB Output is correct
3 Correct 25 ms 604 KB Output is correct
4 Correct 28 ms 600 KB Output is correct
5 Correct 42 ms 680 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 484 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 8 ms 604 KB Output is correct
11 Correct 0 ms 456 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 7 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 600 KB Output is correct
2 Correct 52 ms 668 KB Output is correct
3 Correct 46 ms 596 KB Output is correct
4 Correct 53 ms 668 KB Output is correct
5 Correct 52 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 15 ms 624 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 67 ms 604 KB Output is correct
15 Correct 57 ms 672 KB Output is correct
16 Correct 48 ms 612 KB Output is correct
17 Correct 57 ms 604 KB Output is correct
18 Correct 72 ms 652 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 13 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 145 ms 748 KB Output is correct
28 Correct 163 ms 696 KB Output is correct
29 Correct 133 ms 632 KB Output is correct
30 Correct 122 ms 716 KB Output is correct
31 Correct 145 ms 932 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 33 ms 604 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 14 ms 1628 KB Output is correct
41 Correct 17 ms 1628 KB Output is correct
42 Correct 11 ms 1548 KB Output is correct
43 Correct 9 ms 1428 KB Output is correct
44 Correct 15 ms 1856 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 5 ms 860 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 3 ms 600 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 10 ms 1480 KB Output is correct
53 Correct 31 ms 872 KB Output is correct
54 Correct 30 ms 836 KB Output is correct
55 Correct 25 ms 604 KB Output is correct
56 Correct 28 ms 600 KB Output is correct
57 Correct 42 ms 680 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 3 ms 484 KB Output is correct
60 Correct 1 ms 452 KB Output is correct
61 Correct 3 ms 348 KB Output is correct
62 Correct 8 ms 604 KB Output is correct
63 Correct 0 ms 456 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 7 ms 604 KB Output is correct
66 Execution timed out 5010 ms 18756 KB Time limit exceeded
67 Halted 0 ms 0 KB -