結果

問題 No.1703 Much Matching
ユーザー abc3abc3
提出日時 2021-10-08 23:58:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 201,272 KB
実行使用メモリ 11,232 KB
最終ジャッジ日時 2024-07-23 08:30:31
合計ジャッジ時間 4,706 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 6 ms
9,440 KB
testcase_04 AC 5 ms
9,312 KB
testcase_05 AC 7 ms
10,076 KB
testcase_06 AC 47 ms
9,184 KB
testcase_07 AC 8 ms
9,568 KB
testcase_08 AC 59 ms
10,464 KB
testcase_09 AC 64 ms
10,468 KB
testcase_10 AC 11 ms
6,944 KB
testcase_11 AC 18 ms
10,208 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 26 ms
9,952 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 17 ms
10,476 KB
testcase_16 AC 31 ms
8,928 KB
testcase_17 AC 38 ms
10,732 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 77 ms
9,184 KB
testcase_20 AC 10 ms
6,944 KB
testcase_21 AC 93 ms
10,976 KB
testcase_22 AC 42 ms
10,084 KB
testcase_23 AC 31 ms
10,976 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 7 ms
8,668 KB
testcase_26 AC 23 ms
10,080 KB
testcase_27 AC 40 ms
10,848 KB
testcase_28 AC 84 ms
11,228 KB
testcase_29 AC 19 ms
9,980 KB
testcase_30 AC 25 ms
9,820 KB
testcase_31 AC 7 ms
10,212 KB
testcase_32 AC 45 ms
9,440 KB
testcase_33 AC 35 ms
10,332 KB
testcase_34 AC 5 ms
6,944 KB
testcase_35 AC 11 ms
9,824 KB
testcase_36 AC 195 ms
11,232 KB
testcase_37 AC 9 ms
11,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    using P=pair<int,int>;
    const int INF=1001001001;
    const int mod=1e9+7;
    
    int p[1005][1005],dp[1005][1005];

    void solve(){
        int n,m,q;
        cin>>n>>m>>q;
        rep(i,q){
            int a,b;
            cin>>a>>b;
            p[a][b]=1;
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(p[i][j]){chmax(dp[i][j],dp[i-1][j-1]+p[i][j]);}
                else{chmax(dp[i][j],max(dp[i-1][j],dp[i][j-1]));}
            }
        }
        cout<<dp[n][m]<<endl;
    } 
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve(); 
        
        return 0;
    }
0