結果

問題 No.1703 Much Matching
ユーザー Manuel1024Manuel1024
提出日時 2022-12-12 23:56:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 80,092 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-24 13:20:36
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 5 ms
6,016 KB
testcase_06 AC 115 ms
5,376 KB
testcase_07 AC 8 ms
5,376 KB
testcase_08 AC 124 ms
6,656 KB
testcase_09 AC 140 ms
5,760 KB
testcase_10 AC 21 ms
5,376 KB
testcase_11 AC 33 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 55 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 29 ms
6,016 KB
testcase_16 AC 76 ms
5,376 KB
testcase_17 AC 88 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 184 ms
5,760 KB
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 218 ms
6,272 KB
testcase_22 AC 86 ms
6,400 KB
testcase_23 AC 66 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 45 ms
6,144 KB
testcase_27 AC 95 ms
5,376 KB
testcase_28 AC 181 ms
7,168 KB
testcase_29 AC 36 ms
5,376 KB
testcase_30 AC 51 ms
5,376 KB
testcase_31 AC 7 ms
5,376 KB
testcase_32 AC 98 ms
5,760 KB
testcase_33 AC 67 ms
6,272 KB
testcase_34 AC 7 ms
5,376 KB
testcase_35 AC 18 ms
5,376 KB
testcase_36 AC 425 ms
7,936 KB
testcase_37 AC 8 ms
7,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, m, q; cin >> n >> m >> q;
    vector<vector<bool>> pa(n+10, vector<bool>(m+10, false));
    for(int i = 0; i < q; i++){
        int a, b; cin >> a >> b;
        pa[a][b] = true;
    }

    vector<vector<int>> dp(n+10, vector<int>(m+10, 0));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = dp[i-1][j-1];
            if(pa[i][j]) dp[i][j]++;
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            // cerr << dp[i][j] << " ";
        }
        // cerr << endl;
    }
    int ans = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}
0