結果

問題 No.5 数字のブロック
ユーザー tur1n6tur1n6
提出日時 2017-04-24 22:08:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 61,884 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 13:22:35
合計ジャッジ時間 4,919 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 2 ms
4,352 KB
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,356 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,356 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:17: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
     for(int i; i<N; i++) cin >> W[i];
                ~^~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
double W[1000];

int main(){
    int L, N; cin >> L >> N;
    for(int i; i<N; i++) cin >> W[i];

    sort(W,W+N);

    int e = L;
    int j=0;
    while(e>0){
        e -= W[j];
        j++;
    }

    cout << j-1 << endl;

    return 0;
}
0