結果

問題 No.5 数字のブロック
ユーザー Unbakedbread
提出日時 2025-05-29 00:22:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 263 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 198,276 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-29 00:22:04
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int l,n;cin>>l>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	int sum=0,ans;
	for(ans=0;ans<n;ans++){
		sum+=a[ans];
		if(sum>l) break;
	}cout<<ans<<"\n";
	return 0;
}
0