結果
問題 | No.945 YKC饅頭 |
ユーザー |
![]() |
提出日時 | 2021-03-11 08:29:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,610 ms / 2,000 ms |
コード長 | 872 bytes |
コンパイル時間 | 3,203 ms |
コンパイル使用メモリ | 80,192 KB |
実行使用メモリ | 74,512 KB |
最終ジャッジ日時 | 2024-10-12 22:49:15 |
合計ジャッジ時間 | 55,905 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 74 |
ソースコード
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(); TreeSet<Integer> empty = new TreeSet<>(); for (int i = 1; i <= n; i++) { empty.add(i); } int[] counts = new int[3]; for (int i = 0; i < m; i++) { int left = sc.nextInt(); int right = sc.nextInt(); char type = sc.next().charAt(0); int idx; if (type == 'Y') { idx = 0; } else if (type == 'K') { idx = 1; } else { idx = 2; } Integer key = left - 1; while ((key = empty.higher(key)) != null) { if (key > right) { break; } counts[idx]++; empty.remove(key); } } System.out.println(counts[0] + " " + counts[1] + " " + counts[2]); } }