結果
| 問題 |
No.2353 Guardian Dogs in Spring
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2023-06-16 21:58:27 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 2,000 ms |
| コード長 | 930 bytes |
| コンパイル時間 | 3,451 ms |
| コンパイル使用メモリ | 81,624 KB |
| 実行使用メモリ | 56,988 KB |
| 最終ジャッジ日時 | 2024-06-24 14:08:45 |
| 合計ジャッジ時間 | 16,253 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 |
ソースコード
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;
}
}
ks2m