結果
| 問題 |
No.1703 Much Matching
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-11-09 15:35:33 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,284 bytes |
| コンパイル時間 | 2,371 ms |
| コンパイル使用メモリ | 79,300 KB |
| 実行使用メモリ | 148,720 KB |
| 最終ジャッジ日時 | 2024-11-18 14:59:50 |
| 合計ジャッジ時間 | 79,619 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 WA * 11 TLE * 23 |
ソースコード
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();
}
}
tenten