結果

問題 No.131 マンハッタン距離
ユーザー akakimidoriakakimidori
提出日時 2017-06-09 01:36:02
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 20,524 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 19:56:40
合計ジャッジ時間 1,041 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
testcase_11 AC 0 ms
4,348 KB
testcase_12 AC 0 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 0 ms
4,348 KB
testcase_15 AC 0 ms
4,348 KB
testcase_16 AC 0 ms
4,348 KB
testcase_17 AC 0 ms
4,348 KB
testcase_18 AC 0 ms
4,348 KB
testcase_19 AC 0 ms
4,348 KB
testcase_20 AC 0 ms
4,348 KB
testcase_21 AC 0 ms
4,348 KB
testcase_22 AC 0 ms
4,348 KB
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 0 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d%d%d",&x,&y,&d);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

#define ABS(a) ((a)>=0?(a):-(a))
#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int x,y,d;
  scanf("%d%d%d",&x,&y,&d);

  int s=MIN(x,y);
  int t=x+y-s;

  if(d<=s){
    printf("%d\n",d+1);
  } else if(d<=t){
    printf("%d",s+1);
  } else if(d<=x+y){
    printf("%d\n",x+y-d+1);
  } else {
    printf("0\n");
  }
  return;
}

int main(void){
  run();
  return 0;
}
0