結果

問題 No.5 数字のブロック
ユーザー soy
提出日時 2019-07-27 20:47:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 285 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 59,736 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-02 11:12:32
合計ジャッジ時間 1,637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int w[10000];
int main() {
	int l, n,sum=0,i,ans=0;
	cin >> l >> n;
	for (i = 0; i < n; i++) {
		cin >> w[i];
	}
	sort(w, w + n);
	for (i = 0; i < n; i++) {
		sum += w[i];
		if (sum <= l)
			ans++;
	}
	cout << ans<<"\n";
}
0