結果
| 問題 |
No.945 YKC饅頭
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-12-10 17:59:51 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,228 bytes |
| コンパイル時間 | 2,998 ms |
| コンパイル使用メモリ | 80,532 KB |
| 実行使用メモリ | 83,692 KB |
| 最終ジャッジ日時 | 2024-06-24 01:56:36 |
| 合計ジャッジ時間 | 69,429 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 67 TLE * 7 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
PriorityQueue<Order> leftQueue = new PriorityQueue<Order>(new Comparator<Order>() {
public int compare(Order o1, Order o2) {
return o1.left - o2.left;
}
});
PriorityQueue<Order> rightQueue = new PriorityQueue<Order>(new Comparator<Order>() {
public int compare(Order o1, Order o2) {
return o1.right - o2.right;
}
});
for (int i = 0; i < m; i++) {
Order or = new Order(i, sc.nextInt(), sc.nextInt(), sc.next().charAt(0));
leftQueue.add(or);
rightQueue.add(or);
}
TreeSet<Order> set = new TreeSet<Order>(new Comparator<Order>() {
public int compare(Order o1, Order o2) {
return o1.idx - o2.idx;
}
});
int[] counts = new int[3];
for (int i = 1; i <= n; i++) {
while (leftQueue.size() > 0 && leftQueue.peek().left == i) {
set.add(leftQueue.poll());
}
if (set.size() == 0) {
continue;
}
counts[set.first().type]++;
while (rightQueue.size() > 0 && rightQueue.peek().right == i) {
set.remove(rightQueue.poll());
}
}
System.out.print(counts[0] + " " + counts[1] + " " + counts[2]);
}
static class Order {
int idx;
int left;
int right;
int type;
public Order (int idx, int left, int right, char typeC) {
this.idx = idx;
this.left = left;
this.right = right;
if (typeC == 'Y') {
type = 0;
} else if (typeC == 'K') {
type = 1;
} else {
type = 2;
}
}
public int hashCode() {
return idx;
}
public boolean equals(Object o) {
Order or = (Order) o;
return idx == or.idx;
}
}
}
htensai