結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 103 ms
6,676 KB
testcase_04 AC 67 ms
6,676 KB
testcase_05 AC 167 ms
6,676 KB
testcase_06 AC 71 ms
6,676 KB
testcase_07 AC 49 ms
6,676 KB
testcase_08 AC 92 ms
6,676 KB
testcase_09 AC 12 ms
6,676 KB
testcase_10 AC 198 ms
6,676 KB
testcase_11 AC 47 ms
6,676 KB
testcase_12 AC 112 ms
6,676 KB
testcase_13 AC 162 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 178 ms
6,676 KB
testcase_17 AC 243 ms
6,676 KB
testcase_18 AC 209 ms
6,676 KB
testcase_19 AC 267 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
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 AC 65 ms
6,676 KB
testcase_30 AC 17 ms
6,676 KB
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 = 0;
    int v = 0;
    while(wa < L){
        wa += w[v];
        if(wa <= L) v++;
    }
    printf("%d",v);
    return 0;
}
0