結果

問題 No.5 数字のブロック
ユーザー daradara_sanma
提出日時 2017-06-27 23:43:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 64,812 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 13:49:30
合計ジャッジ時間 1,355 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int max_width, num, width;
	vector<int> vt;

	cin >> max_width;
	cin >> num;
	while (num--)
	{
		int temp;
		cin >> temp;
		vt.push_back(temp);
	}
	sort(vt.begin(), vt.end());

	for (int cnt = 0; cnt <= num; cnt++)
	{
		max_width -= vt[cnt];
		if ((max_width<=0) || (cnt == num-1))
		{
			printf("%d\n", ++cnt);
			break;
		}
	}
	
	return 0;
}
0