結果

問題 No.156 キャンディー・ボックス
ユーザー ottyajp
提出日時 2015-05-12 16:53:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 58,844 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 00:16:29
合計ジャッジ時間 1,535 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;


int main()
{
	int n,m,t = 0,count = 0;
	cin>>n>>m;
	int c[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
	}

	sort(c,c+(n));
	int ctt = 0 - m;
	for (; ctt <= 0; ++t)
	{
		count++;
		ctt += c[t];
	}

	cout<<count-1<<endl;
	return 0;
}
0