結果

問題 No.5 数字のブロック
ユーザー takubokudori
提出日時 2017-08-24 18:39:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 70,320 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 11:38:46
合計ジャッジ時間 2,069 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,s,e) for(int i=s;i<e;i++)
using namespace std;

typedef pair<int, int> pii;
int main(void) {
	int a,b,c;
	std::priority_queue<int,vector<int>,greater<int> > pq;
	cin>>a>>b;
	rep(i,b)cin>>c,pq.push(c);
	int k=0;
	int z=0;
	while(!pq.empty()){
		int t=pq.top();
		pq.pop();
		if(t+z>a)break;
		z+=t;
		k++;
	}
	cout<<k<<endl;
	return 0;
}
0