結果
問題 | No.1557 Binary Variable |
ユーザー | tenten |
提出日時 | 2022-09-30 11:41:52 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 675 ms / 2,000 ms |
コード長 | 1,699 bytes |
コンパイル時間 | 2,080 ms |
コンパイル使用メモリ | 77,836 KB |
実行使用メモリ | 64,280 KB |
最終ジャッジ日時 | 2024-06-02 02:23:49 |
合計ジャッジ時間 | 24,461 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 317 ms
63,388 KB |
testcase_01 | AC | 332 ms
63,152 KB |
testcase_02 | AC | 49 ms
50,152 KB |
testcase_03 | AC | 48 ms
50,512 KB |
testcase_04 | AC | 425 ms
63,376 KB |
testcase_05 | AC | 422 ms
63,464 KB |
testcase_06 | AC | 401 ms
63,600 KB |
testcase_07 | AC | 411 ms
63,368 KB |
testcase_08 | AC | 469 ms
63,496 KB |
testcase_09 | AC | 488 ms
63,184 KB |
testcase_10 | AC | 637 ms
63,608 KB |
testcase_11 | AC | 622 ms
63,632 KB |
testcase_12 | AC | 476 ms
63,424 KB |
testcase_13 | AC | 651 ms
63,744 KB |
testcase_14 | AC | 664 ms
63,784 KB |
testcase_15 | AC | 615 ms
63,832 KB |
testcase_16 | AC | 621 ms
63,968 KB |
testcase_17 | AC | 600 ms
63,760 KB |
testcase_18 | AC | 660 ms
63,500 KB |
testcase_19 | AC | 645 ms
63,748 KB |
testcase_20 | AC | 646 ms
64,280 KB |
testcase_21 | AC | 675 ms
63,888 KB |
testcase_22 | AC | 656 ms
63,792 KB |
testcase_23 | AC | 601 ms
63,560 KB |
testcase_24 | AC | 644 ms
63,684 KB |
testcase_25 | AC | 667 ms
63,700 KB |
testcase_26 | AC | 653 ms
63,820 KB |
testcase_27 | AC | 603 ms
63,904 KB |
testcase_28 | AC | 641 ms
63,912 KB |
testcase_29 | AC | 581 ms
63,668 KB |
testcase_30 | AC | 647 ms
64,092 KB |
testcase_31 | AC | 633 ms
63,552 KB |
testcase_32 | AC | 662 ms
64,000 KB |
testcase_33 | AC | 670 ms
63,836 KB |
testcase_34 | AC | 48 ms
50,476 KB |
testcase_35 | AC | 47 ms
50,520 KB |
testcase_36 | AC | 47 ms
50,428 KB |
ソースコード
import java.io.*; import java.util.*; 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 = 0; int count = 0; for (Unit x : units) { if (prev < x.left) { count++; prev = x.right; } } System.out.println(n - count); } 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 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 String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }