結果
問題 | No.131 マンハッタン距離 |
ユーザー |
![]() |
提出日時 | 2017-09-25 02:08:04 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 140 ms / 5,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 2,280 ms |
コンパイル使用メモリ | 74,576 KB |
実行使用メモリ | 54,500 KB |
最終ジャッジ日時 | 2024-11-14 07:37:35 |
合計ジャッジ時間 | 6,983 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import java.util.*; // Yuki 131 // https://yukicoder.me/problems/no/131 public class Main { public static void main (String[] args) throws InterruptedException { Scanner in = new Scanner(System.in); int x = in.nextInt(); int y = in.nextInt(); int d = in.nextInt(); int answer = 0; if (d <= y) { answer = Math.min(d, x) + 1; } else if (d <= x) { answer = Math.min(d, y) + 1; } else { int crossX = d - y; if (0 <= crossX && crossX <= x) { int crossY = 0 - x + d; answer = y - crossY + 1; } } System.out.println(answer); } }