結果
| 問題 | No.131 マンハッタン距離 | 
| コンテスト | |
| ユーザー |  htensai | 
| 提出日時 | 2019-12-17 17:23:58 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 49 ms / 5,000 ms | 
| コード長 | 607 bytes | 
| コンパイル時間 | 2,056 ms | 
| コンパイル使用メモリ | 74,472 KB | 
| 実行使用メモリ | 37,184 KB | 
| 最終ジャッジ日時 | 2024-07-04 01:49:57 | 
| 合計ジャッジ時間 | 3,947 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 24 | 
ソースコード
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 3);
        int x = Integer.parseInt(first[0]);
        int y = Integer.parseInt(first[1]);
        int d = Integer.parseInt(first[2]);
        if (x + y < d) {
            System.out.println(0);
            return;
        }
        int x1 = Math.min(d, x);
        int x2 = Math.max(0, d - y);
        System.out.println(Math.abs(x1 - x2) + 1);
    }
}
            
            
            
        