結果

問題 No.5 数字のブロック
ユーザー c_l_beanc_l_bean
提出日時 2016-11-24 12:44:55
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 12:54:56
合計ジャッジ時間 2,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
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 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:30:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |   scanf("%d",&l);
      |   ^~~~~~~~~~~~~~
main.c:31:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c:35:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |     scanf("%d",b+i);
      |     ^~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

#define L_MAX 10000

void n_block(int l,int n,int *block){
  int counter = 0,i = 0,l_sum = 0,sum = L_MAX,p;
  int *a;
  while(l_sum < l){
  counter++;
    for(i=0;i<n;i++){
      if(p < *(block+i) && *(block+i) < sum){
	sum = *(block+i);
	a = block+i;
      }
    }
    printf("%d ",sum);
    l_sum += sum;
    p = sum;
    sum = L_MAX;
    *a = L_MAX;
  }
  printf("%d\n",counter-1);
}

int main(){
  int l,n,*b;
  b = (int*)malloc(sizeof(int));

  scanf("%d",&l);
  scanf("%d",&n);

  int i;
  for(i=0;i<n;i++){
    scanf("%d",b+i);
  }

  n_block(l,n,b);

  return 0;
}
0