結果

問題 No.370 道路の掃除
ユーザー HankHank
提出日時 2016-05-24 19:52:33
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:22:04
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
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 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d %d",&n,&m);
      |   ^~~~~~~~~~~~~~~~~~~~
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",&d[i]);
      |     ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int main(){
  int n, m, *d;
  int i,j,buff;
  int min, d_num, d_inside=0;
  int result = 0;
  
  scanf("%d %d",&n,&m);
  
  d=(int*)malloc(sizeof(int)*n);
  for(i=0;i<m;i++){
    scanf("%d",&d[i]);
  }

  //-----sort--------
  for(i=0;i<m-1;i++){
    min = 10000;
    for(j=i;j<m;j++){
      buff=abs(d[j]-d_inside);
      if(buff<min){
	min = buff;
	d_num = j;
      } 
    }
     d_inside=d[d_num];
     buff=d[i];
     d[i]=d[d_num];
     d[d_num]=buff;
  }
  //-----------------
  result += abs(d[0]);
  for(i=1;i<n;i++){
    result += abs(d[i]-d[i-1]);
  }
  printf("%daaa\n",result);

  free(d);
  return 0;
}
0