結果

問題 No.2353 Guardian Dogs in Spring
ユーザー ks2mks2m
提出日時 2023-06-16 21:58:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 3,607 ms
コンパイル使用メモリ 77,692 KB
実行使用メモリ 58,620 KB
最終ジャッジ日時 2023-09-06 19:43:28
合計ジャッジ時間 16,128 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
53,524 KB
testcase_01 AC 78 ms
52,568 KB
testcase_02 AC 80 ms
52,544 KB
testcase_03 AC 79 ms
52,568 KB
testcase_04 AC 79 ms
52,936 KB
testcase_05 AC 202 ms
58,620 KB
testcase_06 AC 209 ms
58,136 KB
testcase_07 AC 207 ms
57,348 KB
testcase_08 AC 211 ms
57,520 KB
testcase_09 AC 210 ms
56,768 KB
testcase_10 AC 210 ms
57,320 KB
testcase_11 AC 205 ms
56,620 KB
testcase_12 AC 219 ms
57,604 KB
testcase_13 AC 215 ms
57,056 KB
testcase_14 AC 98 ms
53,028 KB
testcase_15 AC 209 ms
57,180 KB
testcase_16 AC 210 ms
57,040 KB
testcase_17 AC 214 ms
57,336 KB
testcase_18 AC 203 ms
57,452 KB
testcase_19 AC 211 ms
57,176 KB
testcase_20 AC 86 ms
52,728 KB
testcase_21 AC 123 ms
53,204 KB
testcase_22 AC 176 ms
55,240 KB
testcase_23 AC 208 ms
57,188 KB
testcase_24 AC 121 ms
52,244 KB
testcase_25 AC 117 ms
51,484 KB
testcase_26 AC 115 ms
52,308 KB
testcase_27 AC 86 ms
51,352 KB
testcase_28 AC 123 ms
52,996 KB
testcase_29 AC 194 ms
56,728 KB
testcase_30 AC 176 ms
53,960 KB
testcase_31 AC 189 ms
56,672 KB
testcase_32 AC 205 ms
55,484 KB
testcase_33 AC 211 ms
56,996 KB
testcase_34 AC 201 ms
57,284 KB
testcase_35 AC 216 ms
55,096 KB
testcase_36 AC 137 ms
52,244 KB
testcase_37 AC 111 ms
53,608 KB
testcase_38 AC 177 ms
54,304 KB
testcase_39 AC 181 ms
55,012 KB
testcase_40 AC 184 ms
56,624 KB
testcase_41 AC 190 ms
57,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> {
			if (o1.x != o2.x) {
				return o1.x - o2.x;
			}
			return o1.y - o2.y;
		});
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.i = i;
			o.x = Integer.parseInt(sa[0]);
			o.y = Integer.parseInt(sa[1]);
			que.add(o);
		}
		br.close();

		PrintWriter pw = new PrintWriter(System.out);
		pw.println(n / 2);
		while (que.size() >= 2) {
			Obj o1 = que.poll();
			Obj o2 = que.poll();
			pw.println((o1.i + 1) + " " + (o2.i + 1));
		}
		pw.flush();
	}

	static class Obj {
		int i, x, y;
	}
}
0