結果
問題 | No.1703 Much Matching |
ユーザー | tenten |
提出日時 | 2021-11-09 15:35:33 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,284 bytes |
コンパイル時間 | 2,221 ms |
コンパイル使用メモリ | 79,316 KB |
実行使用メモリ | 75,600 KB |
最終ジャッジ日時 | 2024-04-29 11:55:54 |
合計ジャッジ時間 | 7,009 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
42,336 KB |
testcase_01 | AC | 51 ms
36,756 KB |
testcase_02 | AC | 54 ms
36,872 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int q = sc.nextInt(); Person[] persons = new Person[q + 1]; persons[0] = new Person(0, 0); ArrayList<ArrayList<Integer>> dp = new ArrayList<>(); dp.add(new ArrayList<>()); dp.get(0).add(0); for (int i = 1; i <= q; i++) { persons[i] = new Person(sc.nextInt(), sc.nextInt()); for (int j = dp.size() - 1; j >= 0; j--) { boolean ok = false; for (int x : dp.get(j)) { if (persons[x].enable(persons[i])) { if (j == dp.size() - 1) { dp.add(new ArrayList<>()); } dp.get(j + 1).add(i); ok = true; break; } } if (ok) { break; } } } System.out.println(dp.size() - 1); } static class Person { int left; int right; public Person(int left, int right) { this.left = left; this.right = right; } public boolean enable(Person another) { return left < another.left && right < another.right; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); 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 nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }