結果

問題 No.5 数字のブロック
コンテスト
ユーザー mamo_ICE
提出日時 2022-12-11 11:56:40
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 457 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 38,724 KB
最終ジャッジ日時 2026-02-22 09:53:29
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void){
    short L, N, w[10000], i, j, tmp, l, n = 0;
    
    scanf("%hd\n%hd\n", &L, &N);
    l = tmp = L;
    for(i=0; i<N; i++) scanf("%hd ", &w[i]);
    while(1){
        for(i=0; i<N; i++){
            if(tmp >= w[i]){
                tmp = w[i];
                j = i;
            }
        }
        if((l-=tmp) < 0) break;
        w[j] = tmp = L + 1;
        n++;
    }
    
    printf("%hd\n", n);
    
    return 0;
}
0