結果

問題 No.5 数字のブロック
ユーザー UK_kkbjUK_kkbj
提出日時 2017-06-16 16:21:34
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 13:34:30
合計ジャッジ時間 3,085 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 WA -
testcase_03 AC 90 ms
6,676 KB
testcase_04 AC 56 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 61 ms
6,676 KB
testcase_07 AC 40 ms
6,676 KB
testcase_08 AC 82 ms
6,676 KB
testcase_09 AC 9 ms
6,676 KB
testcase_10 AC 179 ms
6,676 KB
testcase_11 AC 39 ms
6,676 KB
testcase_12 AC 97 ms
6,676 KB
testcase_13 AC 142 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 158 ms
6,676 KB
testcase_17 AC 221 ms
6,676 KB
testcase_18 AC 190 ms
6,676 KB
testcase_19 AC 249 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
void sort(int a[], int n){
    int i, j;
    
    for(i = 0; i < n-i; i++){
        for(j = n-1; j > i; j--){
            if( a[j-1] > a[j] ){
                int temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }
}
int main(void){
    int L, N, i;
    scanf("%d%d",&L, &N);
    int w[N];
    for(i = 0; i < N; i++)
        scanf("%d",&w[i]);
    sort(w, N);
    int wa;
    int v = 0;
    while(wa < L){
        wa += w[v];
        if(wa < L) v++;
    }
    printf("%d",v);
    return 0;
}
0