結果

問題 No.1557 Binary Variable
ユーザー ks2mks2m
提出日時 2021-06-25 21:31:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 771 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 3,037 ms
コンパイル使用メモリ 75,768 KB
実行使用メモリ 64,440 KB
最終ジャッジ日時 2023-09-07 14:12:55
合計ジャッジ時間 27,949 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 444 ms
62,952 KB
testcase_01 AC 448 ms
62,396 KB
testcase_02 AC 52 ms
49,756 KB
testcase_03 AC 52 ms
49,864 KB
testcase_04 AC 535 ms
62,764 KB
testcase_05 AC 531 ms
63,052 KB
testcase_06 AC 514 ms
62,840 KB
testcase_07 AC 521 ms
62,604 KB
testcase_08 AC 595 ms
62,776 KB
testcase_09 AC 648 ms
61,420 KB
testcase_10 AC 690 ms
63,624 KB
testcase_11 AC 670 ms
63,580 KB
testcase_12 AC 602 ms
63,140 KB
testcase_13 AC 661 ms
63,940 KB
testcase_14 AC 740 ms
63,612 KB
testcase_15 AC 665 ms
63,324 KB
testcase_16 AC 737 ms
63,548 KB
testcase_17 AC 726 ms
63,560 KB
testcase_18 AC 761 ms
63,496 KB
testcase_19 AC 766 ms
63,180 KB
testcase_20 AC 718 ms
64,044 KB
testcase_21 AC 762 ms
63,532 KB
testcase_22 AC 771 ms
63,480 KB
testcase_23 AC 743 ms
63,808 KB
testcase_24 AC 703 ms
64,252 KB
testcase_25 AC 731 ms
63,880 KB
testcase_26 AC 702 ms
63,152 KB
testcase_27 AC 704 ms
63,320 KB
testcase_28 AC 716 ms
63,388 KB
testcase_29 AC 709 ms
63,696 KB
testcase_30 AC 714 ms
63,584 KB
testcase_31 AC 757 ms
64,440 KB
testcase_32 AC 769 ms
63,764 KB
testcase_33 AC 759 ms
64,140 KB
testcase_34 AC 55 ms
50,252 KB
testcase_35 AC 57 ms
48,380 KB
testcase_36 AC 55 ms
49,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		Obj[] arr = new Obj[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.l = Integer.parseInt(sa[0]);
			o.r = Integer.parseInt(sa[1]);
			arr[i] = o;
		}
		br.close();

		Arrays.sort(arr, (o1, o2) -> o1.r - o2.r);
		int cnt = 0;
		int x = 0;
		for (int i = 0; i < m; i++) {
			Obj o = arr[i];
			if (x < o.l) {
				x = o.r;
				cnt++;
			}
		}
		System.out.println(n - cnt);
	}

	static class Obj {
		int l, r;
	}
}
0