結果

問題 No.1034 テスターのふっぴーさん
ユーザー ks2mks2m
提出日時 2020-04-24 21:55:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 50,396 KB
最終ジャッジ日時 2024-04-23 03:13:53
合計ジャッジ時間 4,811 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,176 KB
testcase_01 AC 56 ms
50,272 KB
testcase_02 AC 55 ms
50,140 KB
testcase_03 AC 54 ms
50,008 KB
testcase_04 AC 53 ms
50,296 KB
testcase_05 AC 56 ms
50,280 KB
testcase_06 AC 55 ms
50,232 KB
testcase_07 AC 55 ms
50,016 KB
testcase_08 AC 55 ms
50,052 KB
testcase_09 AC 54 ms
50,164 KB
testcase_10 AC 54 ms
50,264 KB
testcase_11 AC 55 ms
50,236 KB
testcase_12 AC 54 ms
50,284 KB
testcase_13 AC 55 ms
50,192 KB
testcase_14 AC 54 ms
50,212 KB
testcase_15 AC 55 ms
50,256 KB
testcase_16 AC 54 ms
50,204 KB
testcase_17 AC 54 ms
50,320 KB
testcase_18 AC 54 ms
50,280 KB
testcase_19 AC 55 ms
50,032 KB
testcase_20 AC 62 ms
50,300 KB
testcase_21 AC 61 ms
50,244 KB
testcase_22 AC 60 ms
50,248 KB
testcase_23 AC 62 ms
50,176 KB
testcase_24 AC 62 ms
50,276 KB
testcase_25 AC 60 ms
50,088 KB
testcase_26 AC 61 ms
50,396 KB
testcase_27 AC 61 ms
50,236 KB
testcase_28 AC 60 ms
50,368 KB
testcase_29 AC 63 ms
50,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int q = Integer.parseInt(br.readLine());
		for (int i = 0; i < q; i++) {
			String[] sa = br.readLine().split(" ");
			long n = Integer.parseInt(sa[0]);
			long x = Integer.parseInt(sa[1]);
			long y = Integer.parseInt(sa[2]);

			long m = n - 1;
			long min = Math.min(x, m - x);
			min = Math.min(min, y);
			min = Math.min(min, m - y);
			long ans = -1;
			if (min > 0) {
				m -= min * 2;
				ans += n * min * 4;
				ans -= min * min * 4;
			}
			x -= min;
			y -= min;

			if (x == 0) {
				System.out.println(ans + y + 1);
			} else {
				ans += m;
				if (y == m) {
					System.out.println(ans + x + 1);
				} else {
					ans += m;
					if (x == m) {
						System.out.println(ans + m - y + 1);
					} else {
						ans += m;
						System.out.println(ans + m - x + 1);
					}
				}
			}
		}
		br.close();
	}
}
0