結果
問題 | No.1557 Binary Variable |
ユーザー | tenten |
提出日時 | 2023-02-21 08:34:08 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 723 ms / 2,000 ms |
コード長 | 2,172 bytes |
コンパイル時間 | 4,263 ms |
コンパイル使用メモリ | 91,456 KB |
実行使用メモリ | 53,908 KB |
最終ジャッジ日時 | 2024-07-21 21:54:41 |
合計ジャッジ時間 | 27,320 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 347 ms
52,868 KB |
testcase_01 | AC | 377 ms
52,300 KB |
testcase_02 | AC | 50 ms
37,120 KB |
testcase_03 | AC | 50 ms
36,924 KB |
testcase_04 | AC | 451 ms
52,784 KB |
testcase_05 | AC | 469 ms
52,352 KB |
testcase_06 | AC | 444 ms
52,704 KB |
testcase_07 | AC | 477 ms
53,280 KB |
testcase_08 | AC | 554 ms
52,812 KB |
testcase_09 | AC | 518 ms
52,732 KB |
testcase_10 | AC | 709 ms
52,836 KB |
testcase_11 | AC | 720 ms
53,032 KB |
testcase_12 | AC | 499 ms
52,284 KB |
testcase_13 | AC | 690 ms
53,572 KB |
testcase_14 | AC | 708 ms
53,576 KB |
testcase_15 | AC | 723 ms
53,116 KB |
testcase_16 | AC | 715 ms
53,088 KB |
testcase_17 | AC | 668 ms
53,708 KB |
testcase_18 | AC | 706 ms
53,600 KB |
testcase_19 | AC | 694 ms
53,768 KB |
testcase_20 | AC | 704 ms
53,908 KB |
testcase_21 | AC | 713 ms
53,900 KB |
testcase_22 | AC | 678 ms
53,332 KB |
testcase_23 | AC | 711 ms
53,460 KB |
testcase_24 | AC | 718 ms
53,352 KB |
testcase_25 | AC | 693 ms
53,616 KB |
testcase_26 | AC | 697 ms
53,164 KB |
testcase_27 | AC | 708 ms
53,344 KB |
testcase_28 | AC | 699 ms
53,268 KB |
testcase_29 | AC | 700 ms
53,708 KB |
testcase_30 | AC | 690 ms
53,504 KB |
testcase_31 | AC | 708 ms
53,704 KB |
testcase_32 | AC | 654 ms
53,104 KB |
testcase_33 | AC | 688 ms
53,468 KB |
testcase_34 | AC | 48 ms
36,900 KB |
testcase_35 | AC | 47 ms
36,848 KB |
testcase_36 | AC | 47 ms
37,124 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); Unit[] units = new Unit[m]; for (int i = 0; i < m; i++) { units[i] = new Unit(sc.nextInt(), sc.nextInt()); } Arrays.sort(units); int prev = -1; for (Unit x : units) { if (prev < x.left) { n--; prev = x.right; } } System.out.println(n); } static class Unit implements Comparable<Unit> { int left; int right; public Unit(int left, int right) { this.left = left; this.right = right; } public int compareTo(Unit another) { return right - another.right; } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }