結果
問題 | No.131 マンハッタン距離 |
ユーザー |
![]() |
提出日時 | 2018-07-14 16:49:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 139 ms / 5,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 2,321 ms |
コンパイル使用メモリ | 74,000 KB |
実行使用メモリ | 54,352 KB |
最終ジャッジ日時 | 2024-10-10 19:03:22 |
合計ジャッジ時間 | 6,953 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int y = scan.nextInt(); int d = scan.nextInt(); scan.close(); if(x + y < d) { System.out.println(0); System.exit(0); } if(x >= d && y >= d) { System.out.println(d + 1); }else if(x < d && y >= d) { int ans = d + 1 - (d - x); System.out.println(ans); }else if(x >= d && y < d) { int ans = d + 1 - (d - y); System.out.println(ans); }else { int ans = d + 1 - (d - x) - (d - y); System.out.println(ans); } } }