結果

問題 No.1703 Much Matching
ユーザー phsplsphspls
提出日時 2022-10-08 11:28:21
言語 Rust
(1.77.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,147 bytes
コンパイル時間 3,763 ms
コンパイル使用メモリ 149,252 KB
実行使用メモリ 26,184 KB
最終ジャッジ日時 2023-09-04 13:32:20
合計ジャッジ時間 9,624 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 6 ms
4,384 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 9 ms
6,684 KB
testcase_06 AC 53 ms
9,512 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 61 ms
12,644 KB
testcase_09 AC 65 ms
11,812 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 19 ms
6,136 KB
testcase_12 AC 5 ms
4,384 KB
testcase_13 AC 27 ms
6,412 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 20 ms
7,992 KB
testcase_16 AC 34 ms
6,372 KB
testcase_17 AC 42 ms
7,468 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 83 ms
12,804 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 98 ms
15,124 KB
testcase_22 AC 45 ms
10,640 KB
testcase_23 AC 32 ms
7,140 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 27 ms
8,792 KB
testcase_27 AC 44 ms
7,724 KB
testcase_28 AC 86 ms
15,784 KB
testcase_29 AC 20 ms
6,952 KB
testcase_30 AC 27 ms
7,136 KB
testcase_31 AC 6 ms
4,380 KB
testcase_32 AC 48 ms
10,104 KB
testcase_33 AC 37 ms
10,036 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 10 ms
4,384 KB
testcase_36 AC 187 ms
26,184 KB
testcase_37 AC 16 ms
10,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nmq = String::new();
    std::io::stdin().read_line(&mut nmq).ok();
    let nmq: Vec<usize> = nmq.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nmq[0];
    let m = nmq[1];
    let q = nmq[2];
    let queries = (0..q).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            (temp[0]-1, temp[1]-1)
        })
        .collect::<Vec<_>>();

    let mut checked = vec![vec![false; m]; n];
    for &(a, b) in queries.iter() { checked[a][b] = true; }
    let mut dp = vec![vec![0usize; m+1]; n+1];
    for i in 0..=n {
        for j in 0..=m {
            if i+1 <= n {
                dp[i+1][j] = dp[i+1][j].max(dp[i][j]);
            }
            if j+1 <= m {
                dp[i][j+1] = dp[i][j+1].max(dp[i][j]);
            }
            if i+1 <= n && j+1 <= m {
                dp[i+1][j+1] = dp[i+1][j+1].max(dp[i][j] + if checked[i][j] { 1 } else { 0 });
            }
        }
    }
    println!("{}", dp[n][m]);
}
0