답안 #902620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902620 2024-01-10T20:59:19 Z SalihSahin Akcija (COCI21_akcija) C++14
30 / 110
79 ms 860 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());
    int mx = 0;

    for(int i = 0; i < n; i++){
        for(int j = min(a[i].first-1, i); j >= max(0LL, mx - (n - i - 1)); 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);
            }

            if(best[j+1].size()) mx = max(mx, j+1);
        }
    }

    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:30: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]
   30 |             while(best[j+1].size() > k){
      |                   ~~~~~~~~~~~~~~~~~^~~
Main.cpp:45: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]
   45 |         if(ans.size() > k) break;
      |            ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 632 KB Output is correct
2 Correct 42 ms 604 KB Output is correct
3 Correct 23 ms 600 KB Output is correct
4 Correct 23 ms 604 KB Output is correct
5 Correct 26 ms 628 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 7 ms 604 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
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 632 KB Output is correct
2 Correct 42 ms 604 KB Output is correct
3 Correct 23 ms 600 KB Output is correct
4 Correct 23 ms 604 KB Output is correct
5 Correct 26 ms 628 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 7 ms 604 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 31 ms 620 KB Output is correct
15 Correct 32 ms 604 KB Output is correct
16 Correct 39 ms 604 KB Output is correct
17 Correct 26 ms 604 KB Output is correct
18 Correct 29 ms 600 KB Output is correct
19 Correct 1 ms 348 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 348 KB Output is correct
23 Correct 12 ms 596 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
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 776 KB Output is correct
2 Correct 76 ms 604 KB Output is correct
3 Correct 79 ms 604 KB Output is correct
4 Correct 64 ms 600 KB Output is correct
5 Correct 76 ms 604 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 17 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 688 KB Output is correct
2 Correct 22 ms 672 KB Output is correct
3 Correct 17 ms 604 KB Output is correct
4 Correct 15 ms 744 KB Output is correct
5 Correct 16 ms 860 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 632 KB Output is correct
2 Correct 42 ms 604 KB Output is correct
3 Correct 23 ms 600 KB Output is correct
4 Correct 23 ms 604 KB Output is correct
5 Correct 26 ms 628 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 7 ms 604 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 31 ms 620 KB Output is correct
15 Correct 32 ms 604 KB Output is correct
16 Correct 39 ms 604 KB Output is correct
17 Correct 26 ms 604 KB Output is correct
18 Correct 29 ms 600 KB Output is correct
19 Correct 1 ms 348 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 348 KB Output is correct
23 Correct 12 ms 596 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 76 ms 776 KB Output is correct
28 Correct 76 ms 604 KB Output is correct
29 Correct 79 ms 604 KB Output is correct
30 Correct 64 ms 600 KB Output is correct
31 Correct 76 ms 604 KB Output is correct
32 Correct 1 ms 352 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 17 ms 604 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Incorrect 0 ms 348 KB Output isn't correct
39 Halted 0 ms 0 KB -