結果

問題 No.2652 [Cherry 6th Tune N] Δρονε χιρχλινγ
ユーザー ks2mks2m
提出日時 2024-02-23 22:25:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,094 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 2,980 ms
コンパイル使用メモリ 84,148 KB
実行使用メモリ 75,008 KB
最終ジャッジ日時 2024-02-23 22:26:58
合計ジャッジ時間 62,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
55,152 KB
testcase_01 AC 750 ms
63,768 KB
testcase_02 AC 727 ms
63,204 KB
testcase_03 AC 729 ms
63,260 KB
testcase_04 AC 764 ms
65,000 KB
testcase_05 AC 803 ms
64,364 KB
testcase_06 AC 785 ms
64,500 KB
testcase_07 AC 843 ms
67,216 KB
testcase_08 AC 909 ms
69,888 KB
testcase_09 AC 910 ms
72,188 KB
testcase_10 AC 841 ms
69,840 KB
testcase_11 AC 896 ms
72,164 KB
testcase_12 AC 862 ms
67,756 KB
testcase_13 AC 892 ms
68,388 KB
testcase_14 AC 951 ms
74,896 KB
testcase_15 AC 947 ms
72,196 KB
testcase_16 AC 861 ms
69,840 KB
testcase_17 AC 887 ms
67,940 KB
testcase_18 AC 909 ms
73,880 KB
testcase_19 AC 899 ms
67,624 KB
testcase_20 AC 956 ms
74,756 KB
testcase_21 AC 975 ms
74,828 KB
testcase_22 AC 1,023 ms
75,008 KB
testcase_23 AC 990 ms
74,876 KB
testcase_24 AC 991 ms
74,860 KB
testcase_25 AC 1,020 ms
74,892 KB
testcase_26 AC 978 ms
74,996 KB
testcase_27 AC 973 ms
74,948 KB
testcase_28 AC 1,020 ms
74,876 KB
testcase_29 AC 970 ms
74,856 KB
testcase_30 AC 1,094 ms
72,848 KB
testcase_31 AC 976 ms
74,828 KB
testcase_32 AC 1,026 ms
74,892 KB
testcase_33 AC 1,039 ms
74,984 KB
testcase_34 AC 1,000 ms
74,832 KB
testcase_35 AC 981 ms
74,876 KB
testcase_36 AC 1,023 ms
74,860 KB
testcase_37 AC 946 ms
75,008 KB
testcase_38 AC 966 ms
74,884 KB
testcase_39 AC 977 ms
74,936 KB
testcase_40 AC 935 ms
74,780 KB
testcase_41 AC 936 ms
74,548 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 t = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			String[] sa = br.readLine().split(" ");
			int n = Integer.parseInt(sa[0]);
			int l = Integer.parseInt(sa[1]);
			int d = Math.max(1, (int) (l / Math.max(1.0, Math.sqrt(n / 1.5))));
			PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> {
				if (o1.x2 != o2.x2) {
					return o1.x2 - o2.x2;
				}
				if (o1.x2 % 2 == 0) {
					return o1.y - o2.y;
				} else {
					return o2.y - o1.y;
				}
			});
			for (int i = 0; i < n; i++) {
				sa = br.readLine().split(" ");
				Obj o = new Obj();
				o.x = Integer.parseInt(sa[0]);
				o.y = Integer.parseInt(sa[1]);
				o.x2 = o.x / d;
				que.add(o);
			}

			pw.println(n);
			while (!que.isEmpty()) {
				Obj o = que.poll();
				pw.println(o.x + " " + o.y);
			}
		}
		pw.flush();
		br.close();
	}

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