結果

問題 No.2315 Flying Camera
ユーザー ks2mks2m
提出日時 2023-05-26 21:23:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 3,282 ms
コンパイル使用メモリ 71,476 KB
実行使用メモリ 56,580 KB
最終ジャッジ日時 2023-08-26 09:52:48
合計ジャッジ時間 9,690 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
56,128 KB
testcase_01 AC 136 ms
55,752 KB
testcase_02 AC 139 ms
55,504 KB
testcase_03 AC 197 ms
55,808 KB
testcase_04 AC 235 ms
56,144 KB
testcase_05 AC 207 ms
56,136 KB
testcase_06 AC 179 ms
55,740 KB
testcase_07 AC 257 ms
56,580 KB
testcase_08 AC 170 ms
55,892 KB
testcase_09 AC 144 ms
55,580 KB
testcase_10 AC 169 ms
56,200 KB
testcase_11 AC 236 ms
55,688 KB
testcase_12 AC 150 ms
55,884 KB
testcase_13 AC 140 ms
56,388 KB
testcase_14 AC 238 ms
56,156 KB
testcase_15 AC 227 ms
55,684 KB
testcase_16 AC 191 ms
56,100 KB
testcase_17 AC 167 ms
55,572 KB
testcase_18 AC 237 ms
56,108 KB
testcase_19 AC 198 ms
56,144 KB
testcase_20 AC 168 ms
56,256 KB
testcase_21 AC 181 ms
55,608 KB
testcase_22 AC 154 ms
56,176 KB
testcase_23 AC 132 ms
55,600 KB
testcase_24 AC 264 ms
56,512 KB
testcase_25 AC 136 ms
55,816 KB
testcase_26 AC 263 ms
56,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= 300; i++) {
			for (int j = 0; j <= 300; j++) {
				int val = 0;
				for (int k = 0; k < n; k++) {
					val += Math.abs(i - x[k]);
					val += Math.abs(j - y[k]);
				}
				ans = Math.min(ans, val);
			}
		}
		System.out.println(ans);
	}
}
0