답안 #767747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767747 2023-06-27T06:35:09 Z drdilyor Akcija (COCI21_akcija) C++17
10 / 110
364 ms 16812 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, k;
    cin >> n >> k;
    vector<pair<int,int>> arr(n);
    for (auto&[cost, d] : arr) cin >> cost >> d;
    assert(n <= 20);

    vector<pair<int,ll>> ans;
    for (int mask = 0; mask < (1<< n); mask++) {
        vector<int> d;
        ll cost = 0;
        for (int i = 0; i < n; i++)
            if (mask&(1 << i)) {
                d.push_back(arr[i].second);
                cost += arr[i].first;
            }

        sort(d.begin(), d.end());

        bool ok = true;
        for (int i = 0; i < (int)d.size(); i++) {
            if (d[i] <= i)ok = false;
        }
        if (ok) ans.emplace_back(__builtin_popcount(mask), -cost);
    }
    sort(ans.begin(), ans.end(), greater<>());

    for (int i = 0; i < k; i++)
        cout << ans[i].first << ' ' << -ans[i].second << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 8648 KB Output is correct
2 Correct 364 ms 16812 KB Output is correct
3 Correct 88 ms 4548 KB Output is correct
4 Correct 75 ms 2500 KB Output is correct
5 Correct 351 ms 16800 KB Output is correct
6 Correct 48 ms 332 KB Output is correct
7 Correct 200 ms 952 KB Output is correct
8 Correct 69 ms 548 KB Output is correct
9 Correct 63 ms 340 KB Output is correct
10 Correct 106 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 152 ms 4524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -