結果

問題 No.5 数字のブロック
ユーザー Tirol_JPNTirol_JPN
提出日時 2016-09-11 17:57:20
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 12:10:55
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 59 ms
5,376 KB
testcase_04 AC 38 ms
5,376 KB
testcase_05 AC 96 ms
5,376 KB
testcase_06 AC 41 ms
5,376 KB
testcase_07 AC 28 ms
5,376 KB
testcase_08 AC 52 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 117 ms
5,376 KB
testcase_11 AC 27 ms
5,376 KB
testcase_12 AC 64 ms
5,376 KB
testcase_13 AC 92 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 100 ms
5,376 KB
testcase_17 AC 137 ms
5,376 KB
testcase_18 AC 120 ms
5,376 KB
testcase_19 AC 152 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 0 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 37 ms
5,376 KB
testcase_30 AC 10 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:24:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |     scanf("%d %d",&l,&n);
      |     ^~~~~~~~~~~~~~~~~~~~
main.c:26:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         scanf("%d",&w[i]);
      |         ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
// ソート
void sort(int n,int w[]){
    int i,j,mini,tmp;
    for(i=0;i<n;i++){
        mini=i;
        for(j=i+1;j<n;j++){
            if(w[j]<w[mini]){
                mini=j;
            }
        }
        if(mini!=i){
            tmp = w[i];
            w[i] = w[mini];
            w[mini] = tmp;
        }
    }
}


int main(int argc, char * argv[]){
    int l,n,ans=0,i,rest;
    int w[10001];
    scanf("%d %d",&l,&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    sort(n,w);
    rest=l;
    i=0;
    while(1){
        rest-=w[i];
        if(rest<0) break;
        ans++;
        i++;
    }
    printf("%d\n",ans);
    return 0;
}
0