結果

問題 No.1703 Much Matching
ユーザー ks2mks2m
提出日時 2021-10-08 22:40:22
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 924 bytes
コンパイル時間 2,560 ms
コンパイル使用メモリ 84,548 KB
実行使用メモリ 120,320 KB
最終ジャッジ日時 2024-07-23 05:45:40
合計ジャッジ時間 39,402 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
60,204 KB
testcase_01 AC 143 ms
54,136 KB
testcase_02 AC 120 ms
53,124 KB
testcase_03 AC 146 ms
54,328 KB
testcase_04 AC 190 ms
54,476 KB
testcase_05 AC 161 ms
54,176 KB
testcase_06 AC 1,835 ms
75,428 KB
testcase_07 AC 407 ms
59,424 KB
testcase_08 AC 1,812 ms
75,868 KB
testcase_09 AC 1,944 ms
81,248 KB
testcase_10 AC 635 ms
59,908 KB
testcase_11 AC 797 ms
66,036 KB
testcase_12 AC 355 ms
58,200 KB
testcase_13 AC 1,060 ms
70,868 KB
testcase_14 AC 246 ms
57,892 KB
testcase_15 AC 710 ms
61,696 KB
testcase_16 AC 1,231 ms
73,176 KB
testcase_17 AC 1,372 ms
73,104 KB
testcase_18 AC 240 ms
57,412 KB
testcase_19 TLE -
testcase_20 AC 682 ms
61,684 KB
testcase_21 TLE -
testcase_22 AC 1,384 ms
73,204 KB
testcase_23 AC 1,039 ms
73,796 KB
testcase_24 AC 231 ms
57,812 KB
testcase_25 AC 433 ms
59,644 KB
testcase_26 AC 883 ms
71,576 KB
testcase_27 AC 1,511 ms
75,248 KB
testcase_28 TLE -
testcase_29 AC 800 ms
66,856 KB
testcase_30 AC 954 ms
70,744 KB
testcase_31 AC 341 ms
59,192 KB
testcase_32 AC 1,431 ms
75,908 KB
testcase_33 AC 1,139 ms
73,308 KB
testcase_34 AC 385 ms
59,240 KB
testcase_35 AC 608 ms
59,732 KB
testcase_36 TLE -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		Obj[] arr = new Obj[q];
		for (int i = 0; i < q; i++) {
			Obj o = new Obj();
			o.a = sc.nextInt();
			o.b = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Arrays.sort(arr, (o1, o2) -> {
			if (o1.a != o2.a) {
				return o1.a - o2.a;
			}
			return o2.b - o1.b;
		});

		int[] dp = new int[m + 1];
		for (int i = 1; i <= m; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		for (int i = 0; i < q; i++) {
			int idx = Arrays.binarySearch(dp, arr[i].b);
			if (idx < 0) idx = ~idx;
			dp[idx] = arr[i].b;
		}

		int lis = Arrays.binarySearch(dp, Integer.MAX_VALUE - 1);
		if (lis < 0) {
			lis = ~lis;
			lis--;
		}
		System.out.println(lis);
	}

	static class Obj {
		int a, b;
	}
}
0