結果

問題 No.156 キャンディー・ボックス
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-08 00:32:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 16:23:44
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> C(n);
	for (int i = 0; i < n; i++)
	{
		cin >> C[i];
	}

	sort(C.begin(), C.end());

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		m -= C[i];
		ans += m >= 0 ? 1 : 0;
	}
	cout << ans << endl;
}
0