結果

問題 No.5 数字のブロック
ユーザー fal_rnd
提出日時 2017-02-04 19:09:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 450 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 161,364 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 10:53:42
合計ジャッジ時間 2,231 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

int main() {
	int l,n,result=0;
	cin>>l>>n;

	priority_queue<int,vector<int>,greater<int>> in;
	{
		int j;
		for(int i=0;i<n;i++){
			cin>>j;
			in.push(j);
		}
	}
	int sum=0;
	while(!in.empty()){
		sum+=in.top();
		in.pop();
		result++;
		if(sum>l){
			result--;
			break;
		}
	}

	cout<<result<<en;

	return 0;
}
0