Submission #3027091


Source Code Expand

#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部0にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
char s[500005];

int main(){
    cin>>n>>k;
	for(i=0;i<n;i++)cin>>x[i];
	sort(x,x+n);
	reverse(x,x+n);
	for(i=0;i<n;i++){
		num += x[i];
		if(num>=k){
			p(i+1);
			return 0;
		}
	}
	p(-1);
	return 0;
}

Submission Info

Submission Time
Task A - Credits
User enjapma
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1638 Byte
Status AC
Exec Time 3 ms
Memory 8576 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 3 ms 8576 KB
corner_11 AC 3 ms 8576 KB
corner_12 AC 3 ms 8576 KB
corner_13 AC 3 ms 8576 KB
max_14 AC 3 ms 8576 KB
random_00 AC 3 ms 8576 KB
random_01 AC 3 ms 8576 KB
random_02 AC 2 ms 8576 KB
random_03 AC 3 ms 8576 KB
random_04 AC 3 ms 8576 KB
random_05 AC 2 ms 8576 KB
random_06 AC 3 ms 8576 KB
random_07 AC 3 ms 8576 KB
random_08 AC 3 ms 8576 KB
random_09 AC 3 ms 8576 KB
sample_00 AC 3 ms 8576 KB
sample_01 AC 3 ms 8576 KB
sample_02 AC 3 ms 8576 KB