Submission #2136663


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[51];
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    sort(a,a+n,greater<int>());
    int cnt=0,sum=0;
    rep(i,n){
        sum+=a[i];++cnt;
        if(sum>=k){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Submission Info

Submission Time
Task A - Credits
User ts_
Language C++14 (GCC 5.4.1)
Score 100
Code Size 527 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
Set Name Test Cases
All corner_10, corner_11, corner_12, corner_13, max_14, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, sample_00, sample_01, sample_02
Case Name Status Exec Time Memory
corner_10 AC 1 ms 256 KB
corner_11 AC 1 ms 256 KB
corner_12 AC 1 ms 256 KB
corner_13 AC 1 ms 256 KB
max_14 AC 1 ms 256 KB
random_00 AC 1 ms 256 KB
random_01 AC 1 ms 256 KB
random_02 AC 1 ms 256 KB
random_03 AC 1 ms 256 KB
random_04 AC 1 ms 256 KB
random_05 AC 1 ms 256 KB
random_06 AC 1 ms 256 KB
random_07 AC 1 ms 256 KB
random_08 AC 1 ms 256 KB
random_09 AC 1 ms 256 KB
sample_00 AC 1 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB