結果

問題 No.131 マンハッタン距離
ユーザー ぴろず
提出日時 2015-01-20 23:32:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 74,024 KB
実行使用メモリ 41,228 KB
最終ジャッジ日時 2024-06-22 23:16:09
合計ジャッジ時間 5,710 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

package no131;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(solve(x,y,d));
	}

	public static long solve(long x,long y,long d) {
		if (d > x + y) {
			return 0;
		}
		long right = d <= x ? d : x;
		long left = d <= y ? 0 : d - y;
		return right - left + 1;
	}

}
0