結果

問題 No.1703 Much Matching
ユーザー tentententen
提出日時 2021-11-09 15:54:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 657 ms / 2,000 ms
コード長 1,663 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 77,456 KB
実行使用メモリ 51,744 KB
最終ジャッジ日時 2024-04-29 12:35:48
合計ジャッジ時間 13,648 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,716 KB
testcase_01 AC 55 ms
36,852 KB
testcase_02 AC 52 ms
36,964 KB
testcase_03 AC 78 ms
39,700 KB
testcase_04 AC 89 ms
39,100 KB
testcase_05 AC 82 ms
40,968 KB
testcase_06 AC 382 ms
47,096 KB
testcase_07 AC 150 ms
42,204 KB
testcase_08 AC 414 ms
47,696 KB
testcase_09 AC 435 ms
48,476 KB
testcase_10 AC 197 ms
43,796 KB
testcase_11 AC 239 ms
44,416 KB
testcase_12 AC 151 ms
42,148 KB
testcase_13 AC 285 ms
44,748 KB
testcase_14 AC 122 ms
39,336 KB
testcase_15 AC 222 ms
44,452 KB
testcase_16 AC 314 ms
48,176 KB
testcase_17 AC 325 ms
45,444 KB
testcase_18 AC 121 ms
39,288 KB
testcase_19 AC 473 ms
48,876 KB
testcase_20 AC 185 ms
43,528 KB
testcase_21 AC 485 ms
48,756 KB
testcase_22 AC 335 ms
46,004 KB
testcase_23 AC 290 ms
45,016 KB
testcase_24 AC 104 ms
39,120 KB
testcase_25 AC 157 ms
43,464 KB
testcase_26 AC 263 ms
44,712 KB
testcase_27 AC 345 ms
48,016 KB
testcase_28 AC 517 ms
48,804 KB
testcase_29 AC 241 ms
44,672 KB
testcase_30 AC 275 ms
45,904 KB
testcase_31 AC 152 ms
41,680 KB
testcase_32 AC 361 ms
47,224 KB
testcase_33 AC 295 ms
47,776 KB
testcase_34 AC 139 ms
42,092 KB
testcase_35 AC 189 ms
43,640 KB
testcase_36 AC 657 ms
51,744 KB
testcase_37 AC 99 ms
45,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        boolean[][] check = new boolean[n + 1][m + 1];
        for (int i = 1; i <= q; i++) {
            check[sc.nextInt()][sc.nextInt()] = true;
        }
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (i == 0 && j == 0) {
                    continue;
                }
                if (check[i][j]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        System.out.println(dp[n][m]);
    }
}
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();
    }
}
0