結果
問題 | No.945 YKC饅頭 |
ユーザー | htensai |
提出日時 | 2019-12-10 18:43:32 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,996 ms / 2,000 ms |
コード長 | 2,608 bytes |
コンパイル時間 | 2,713 ms |
コンパイル使用メモリ | 81,752 KB |
実行使用メモリ | 63,592 KB |
最終ジャッジ日時 | 2024-06-24 02:06:55 |
合計ジャッジ時間 | 53,159 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 179 ms
42,616 KB |
testcase_01 | AC | 166 ms
42,688 KB |
testcase_02 | AC | 156 ms
43,036 KB |
testcase_03 | AC | 205 ms
43,144 KB |
testcase_04 | AC | 168 ms
42,536 KB |
testcase_05 | AC | 174 ms
42,932 KB |
testcase_06 | AC | 200 ms
42,648 KB |
testcase_07 | AC | 175 ms
42,644 KB |
testcase_08 | AC | 166 ms
42,500 KB |
testcase_09 | AC | 180 ms
43,284 KB |
testcase_10 | AC | 183 ms
43,044 KB |
testcase_11 | AC | 177 ms
42,888 KB |
testcase_12 | AC | 194 ms
42,732 KB |
testcase_13 | AC | 208 ms
43,464 KB |
testcase_14 | AC | 227 ms
43,772 KB |
testcase_15 | AC | 205 ms
43,152 KB |
testcase_16 | AC | 168 ms
42,788 KB |
testcase_17 | AC | 202 ms
43,348 KB |
testcase_18 | AC | 202 ms
43,264 KB |
testcase_19 | AC | 187 ms
42,656 KB |
testcase_20 | AC | 187 ms
43,036 KB |
testcase_21 | AC | 193 ms
43,104 KB |
testcase_22 | AC | 217 ms
43,392 KB |
testcase_23 | AC | 210 ms
43,184 KB |
testcase_24 | AC | 196 ms
43,440 KB |
testcase_25 | AC | 193 ms
43,468 KB |
testcase_26 | AC | 191 ms
43,484 KB |
testcase_27 | AC | 170 ms
42,688 KB |
testcase_28 | AC | 183 ms
42,848 KB |
testcase_29 | AC | 182 ms
42,692 KB |
testcase_30 | AC | 181 ms
43,004 KB |
testcase_31 | AC | 317 ms
46,856 KB |
testcase_32 | AC | 234 ms
43,708 KB |
testcase_33 | AC | 566 ms
50,680 KB |
testcase_34 | AC | 1,066 ms
56,124 KB |
testcase_35 | AC | 1,622 ms
60,960 KB |
testcase_36 | AC | 1,595 ms
60,640 KB |
testcase_37 | AC | 1,453 ms
60,020 KB |
testcase_38 | AC | 1,256 ms
57,436 KB |
testcase_39 | AC | 447 ms
49,504 KB |
testcase_40 | AC | 418 ms
50,544 KB |
testcase_41 | AC | 300 ms
46,228 KB |
testcase_42 | AC | 1,588 ms
60,400 KB |
testcase_43 | AC | 1,404 ms
60,048 KB |
testcase_44 | AC | 1,288 ms
58,408 KB |
testcase_45 | AC | 1,848 ms
61,920 KB |
testcase_46 | AC | 210 ms
43,536 KB |
testcase_47 | AC | 1,070 ms
55,572 KB |
testcase_48 | AC | 446 ms
50,108 KB |
testcase_49 | AC | 574 ms
51,000 KB |
testcase_50 | AC | 1,843 ms
62,572 KB |
testcase_51 | AC | 1,822 ms
63,592 KB |
testcase_52 | AC | 1,853 ms
62,928 KB |
testcase_53 | AC | 1,826 ms
62,416 KB |
testcase_54 | AC | 1,868 ms
62,360 KB |
testcase_55 | AC | 1,996 ms
62,572 KB |
testcase_56 | AC | 204 ms
42,852 KB |
testcase_57 | AC | 193 ms
42,892 KB |
testcase_58 | AC | 1,228 ms
56,200 KB |
testcase_59 | AC | 1,229 ms
57,280 KB |
testcase_60 | AC | 575 ms
52,280 KB |
testcase_61 | AC | 1,173 ms
56,840 KB |
testcase_62 | AC | 1,135 ms
56,224 KB |
testcase_63 | AC | 235 ms
43,880 KB |
testcase_64 | AC | 603 ms
53,332 KB |
testcase_65 | AC | 539 ms
51,972 KB |
testcase_66 | AC | 507 ms
50,920 KB |
testcase_67 | AC | 838 ms
53,812 KB |
testcase_68 | AC | 571 ms
51,492 KB |
testcase_69 | AC | 374 ms
49,604 KB |
testcase_70 | AC | 407 ms
51,344 KB |
testcase_71 | AC | 403 ms
50,924 KB |
testcase_72 | AC | 687 ms
52,656 KB |
testcase_73 | AC | 1,226 ms
56,712 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); Scanner sc = new Scanner(System.in); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); Order[] leftArr = new Order[m]; Order[] rightArr = new Order[m]; for (int i = 0; i < m; i++) { String[] line = br.readLine().split(" ", 3); Order or = new Order(i, Integer.parseInt(line[0]), Integer.parseInt(line[1]), line[2].charAt(0)); leftArr[i] = or; rightArr[i] = or; } Arrays.sort(leftArr, new Comparator<Order>() { public int compare(Order o1, Order o2) { return o1.left - o2.left; } }); Arrays.sort(rightArr, new Comparator<Order>() { public int compare(Order o1, Order o2) { return o1.right - o2.right; } }); 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]; int leftIdx = 0; int rightIdx = 0; for (int i = 1; i <= n; i++) { while(leftIdx < m && leftArr[leftIdx].left == i) { set.add(leftArr[leftIdx]); leftIdx++; } if (set.size() == 0) { continue; } counts[set.first().type]++; while (rightIdx < m && rightArr[rightIdx].right == i) { set.remove(rightArr[rightIdx]); rightIdx++; } } 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; } } }