結果

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

ソースコード

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());

	int cnt = 0;
	while ((max_width = (max_width - vt[cnt])) >= 0)
	{
		cnt++;
		if (max_width==0)
		{
			break;
		}
		else if (cnt == num)
		{
			break;
		}
	}

	printf("%d\n", cnt);
	
	return 0;
}
0