結果

問題 No.131 マンハッタン距離
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-19 22:10:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 2,839 ms
コンパイル使用メモリ 74,260 KB
実行使用メモリ 54,292 KB
最終ジャッジ日時 2024-04-19 13:02:35
合計ジャッジ時間 6,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
40,304 KB
testcase_01 AC 111 ms
41,304 KB
testcase_02 AC 116 ms
41,144 KB
testcase_03 AC 116 ms
41,128 KB
testcase_04 AC 117 ms
40,096 KB
testcase_05 AC 118 ms
41,812 KB
testcase_06 AC 108 ms
41,736 KB
testcase_07 WA -
testcase_08 AC 109 ms
39,896 KB
testcase_09 AC 117 ms
41,348 KB
testcase_10 AC 102 ms
40,936 KB
testcase_11 WA -
testcase_12 AC 117 ms
41,784 KB
testcase_13 AC 104 ms
41,232 KB
testcase_14 AC 117 ms
40,620 KB
testcase_15 AC 119 ms
41,400 KB
testcase_16 AC 114 ms
40,272 KB
testcase_17 AC 116 ms
40,852 KB
testcase_18 AC 114 ms
40,340 KB
testcase_19 AC 118 ms
41,412 KB
testcase_20 AC 102 ms
41,476 KB
testcase_21 AC 108 ms
40,120 KB
testcase_22 AC 109 ms
40,384 KB
testcase_23 AC 101 ms
39,916 KB
testcase_24 AC 113 ms
41,508 KB
testcase_25 WA -
testcase_26 AC 101 ms
41,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise98{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int d = sc.nextInt();

    int smaller = Math.min(x, y);
    int bigger = Math.max(x, y);

    if(d < smaller){
      System.out.println(d - 1 + 2);
    }else if(d >= smaller && d <= bigger){
      System.out.println(smaller - 1 + 2);
    }else if(d < bigger + smaller){
      System.out.println((bigger + smaller - d) - 1 + 2);
    }else{
      System.out.println(0);
    }
  }
}
0