提出 #72583087


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=500100,INF=2e18,MOD=998244353;
int t,n,k,x,y,z,m,h,j,u,cnt,mi,tt,rr,mx,res,ans,ll,q;
int a[N],b[N],c[N],dp[1100][2100][4];
signed main(){
    cin>>n>>k>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=k;i>=1;i--){
        tt+=a[i];
        if(tt>=x){
            ans=k+1-i;
            break;
        }
    }
    if(tt<x){
        cout<<"-1";
        return 0;
    }
    ans+=n-k;
    cout<<ans;


}

提出情報

提出日時
問題 C - Sake or Water
ユーザ mengqing
言語 C++23 (GCC 15.2.0)
得点 300
コード長 567 Byte
結果 AC
実行時間 88 ms
メモリ 6124 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 33
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3420 KiB
example_01.txt AC 1 ms 3632 KiB
example_02.txt AC 1 ms 3360 KiB
hand_00.txt AC 78 ms 6044 KiB
hand_01.txt AC 78 ms 5852 KiB
hand_02.txt AC 68 ms 6088 KiB
hand_03.txt AC 68 ms 6012 KiB
hand_04.txt AC 67 ms 5980 KiB
hand_05.txt AC 68 ms 6064 KiB
hand_06.txt AC 68 ms 5980 KiB
hand_07.txt AC 1 ms 3480 KiB
hand_08.txt AC 1 ms 3480 KiB
hand_09.txt AC 1 ms 3480 KiB
hand_10.txt AC 1 ms 3632 KiB
hand_11.txt AC 78 ms 6032 KiB
random_00.txt AC 87 ms 5968 KiB
random_01.txt AC 86 ms 6048 KiB
random_02.txt AC 87 ms 6048 KiB
random_03.txt AC 87 ms 6016 KiB
random_04.txt AC 87 ms 5792 KiB
random_05.txt AC 86 ms 6064 KiB
random_06.txt AC 87 ms 5968 KiB
random_07.txt AC 86 ms 6100 KiB
random_08.txt AC 87 ms 6100 KiB
random_09.txt AC 87 ms 5904 KiB
random_10.txt AC 87 ms 5956 KiB
random_11.txt AC 88 ms 5792 KiB
random_12.txt AC 87 ms 6076 KiB
random_13.txt AC 86 ms 5784 KiB
random_14.txt AC 87 ms 6088 KiB
random_15.txt AC 86 ms 5920 KiB
random_16.txt AC 86 ms 6124 KiB
random_17.txt AC 87 ms 6088 KiB