結果
問題 | No.131 マンハッタン距離 |
ユーザー |
![]() |
提出日時 | 2017-06-09 01:36:02 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 392 bytes |
コンパイル時間 | 86 ms |
コンパイル使用メモリ | 20,480 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 13:38:21 |
合計ジャッジ時間 | 857 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
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); | ^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;}