結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
prog470
|
| 提出日時 | 2016-09-07 11:30:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 628 bytes |
| コンパイル時間 | 666 ms |
| コンパイル使用メモリ | 71,388 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-11-15 21:03:36 |
| 合計ジャッジ時間 | 1,784 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 1 |
ソースコード
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
int L, N, W[10005];
cin >> L >> N;
for (int i = 0; i < N; i++) {
cin >> W[i];
}
sort(W, W+N);
int sum = 0,cnt = 0;
while (1) {
if (cnt >= N) break;
if (sum > L) {
cnt--;
break;
}
else if (sum == L) {
break;
}
sum += W[cnt]; //cnt番目が入らない。cntは個数-1だから、cntをそのまま出力で合う。
cnt++;
}
cout << cnt<< endl;
return 0;
}
prog470