結果

問題 No.5 数字のブロック
ユーザー nanatutmc
提出日時 2019-09-20 01:00:29
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 29,312 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 07:49:17
合計ジャッジ時間 1,493 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
    3 | main() {
      | ^~~~

ソースコード

diff #

#include <stdio.h>

main() {
    int L, N;
    int width[10000];
    scanf("%d", &L);
    scanf("%d", &N);
    
    for (int i=0; i<N; i++) {
        scanf("%d", &(width[i]));
    }
    
    // sort
    for (int i=0; i<N-1; i++) {
        if (width[i] > width[i+1]) {
            int tmp = width[i];
            
            width[i] = width[i+1];
            width[i+1] = width[i];
        }
    }
    
    int total = 0;
    for (int i = 0; i<N; i++) {
        total += width[i];
        if (total > L) {
            printf("%d\n", i);
            break;
        }
    }
}
0