Submission #72665473


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)

using ll = long long;

// ======================================== //

int main()
{
    int N, K;
    ll X;
    cin >> N >> K >> X;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    sort(rall(A));

    ll ans = -1, sum = 0;
    rep(m, N - K + 1, N + 1)
    {
        sum += A[m - 1];
        if (sum >= X)
        {
            ans = m;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Submission Info

Submission Time
Task C - Sake or Water
User Yuulis
Language C++23 (GCC 15.2.0)
Score 300
Code Size 613 Byte
Status AC
Exec Time 88 ms
Memory 5916 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 33
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3564 KiB
example_01.txt AC 1 ms 3664 KiB
example_02.txt AC 1 ms 3508 KiB
hand_00.txt AC 79 ms 5748 KiB
hand_01.txt AC 78 ms 5776 KiB
hand_02.txt AC 69 ms 5796 KiB
hand_03.txt AC 69 ms 5836 KiB
hand_04.txt AC 69 ms 5744 KiB
hand_05.txt AC 69 ms 5792 KiB
hand_06.txt AC 68 ms 5776 KiB
hand_07.txt AC 1 ms 3684 KiB
hand_08.txt AC 1 ms 3684 KiB
hand_09.txt AC 1 ms 3632 KiB
hand_10.txt AC 1 ms 3664 KiB
hand_11.txt AC 79 ms 5776 KiB
random_00.txt AC 88 ms 5776 KiB
random_01.txt AC 87 ms 5900 KiB
random_02.txt AC 88 ms 5796 KiB
random_03.txt AC 88 ms 5704 KiB
random_04.txt AC 88 ms 5796 KiB
random_05.txt AC 88 ms 5916 KiB
random_06.txt AC 87 ms 5796 KiB
random_07.txt AC 88 ms 5704 KiB
random_08.txt AC 88 ms 5760 KiB
random_09.txt AC 88 ms 5796 KiB
random_10.txt AC 87 ms 5836 KiB
random_11.txt AC 88 ms 5828 KiB
random_12.txt AC 88 ms 5776 KiB
random_13.txt AC 88 ms 5744 KiB
random_14.txt AC 87 ms 5900 KiB
random_15.txt AC 87 ms 5744 KiB
random_16.txt AC 88 ms 5748 KiB
random_17.txt AC 88 ms 5716 KiB