結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-08-03 00:32:13 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 404 bytes | 
| コンパイル時間 | 499 ms | 
| コンパイル使用メモリ | 60,608 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-20 01:17:56 | 
| 合計ジャッジ時間 | 1,654 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 WA * 7 | 
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
int main(void)
{
    int l, n, c = 0, t = 0;
    cin >> l;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++)
        std::cin >> w[i];
    sort(w, w + SIZE_OF_ARRAY(w));
    while (t < l)
    {
        t += w[c];
        c++;
    }
    c--;
    cout << c << endl;
}