답안 #902619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902619 2024-01-10T20:50:12 Z SalihSahin Akcija (COCI21_akcija) C++17
20 / 110
7 ms 1616 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++){
        int cnt = 0;

        for(int j = a[i].first-1; j >= 0; j--){
            cnt += best[j].size();

            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(cnt > k) break;
        }
    }

    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:33: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]
   33 |             while(best[j+1].size() > k){
      |                   ~~~~~~~~~~~~~~~~~^~~
Main.cpp:48: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]
   48 |         if(ans.size() > k) break;
      |            ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1508 KB Output is correct
2 Correct 5 ms 1372 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 4 ms 1116 KB Output is correct
5 Correct 6 ms 1616 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 4 ms 860 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 4 ms 604 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 1128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Incorrect 2 ms 860 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -