結果

問題 No.5 数字のブロック
ユーザー Tirol_JPNTirol_JPN
提出日時 2016-09-11 17:32:40
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 744 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 12:10:06
合計ジャッジ時間 6,221 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:33:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
   33 |         scanf("%d",w[i]);
      |                ~^  ~~~~
      |                 |   |
      |                 |   int
      |                 int *
main.c:29:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     scanf("%d",&l);
      |     ^~~~~~~~~~~~~~
main.c:30:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     scanf("%d",&n);
      |     ^~~~~~~~~~~~~~
main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%d",w[i]);
      |         ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.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] = w[i];
        }
    }
}


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