結果

問題 No.156 キャンディー・ボックス
ユーザー mmn15277198
提出日時 2020-08-12 20:30:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 96,316 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 18:34:22
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){
	
	long long n,m;
	cin >> n >> m;
	vector<long long> c(n);
	for(long long i=0;i<n;i++)cin >> c[i];
	sort(c.begin(),c.end());
	int ans=0;
	for(long long i=0;i<n;i++){
		m-=c[i];
		if(m>=0){
			ans++;
		}else{
			break;
		}
	}
	cout << ans << endl;	
	
	return 0;
}
0