結果

問題 No.1703 Much Matching
ユーザー abc3abc3
提出日時 2021-10-08 23:58:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 199,464 KB
実行使用メモリ 11,348 KB
最終ジャッジ日時 2023-09-30 14:28:19
合計ジャッジ時間 4,651 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,580 KB
testcase_01 AC 2 ms
5,432 KB
testcase_02 AC 2 ms
5,480 KB
testcase_03 AC 6 ms
9,552 KB
testcase_04 AC 5 ms
9,212 KB
testcase_05 AC 7 ms
9,668 KB
testcase_06 AC 44 ms
9,108 KB
testcase_07 AC 7 ms
10,328 KB
testcase_08 AC 52 ms
10,284 KB
testcase_09 AC 57 ms
10,480 KB
testcase_10 AC 10 ms
8,080 KB
testcase_11 AC 17 ms
9,968 KB
testcase_12 AC 5 ms
7,968 KB
testcase_13 AC 24 ms
9,912 KB
testcase_14 AC 3 ms
7,756 KB
testcase_15 AC 16 ms
10,536 KB
testcase_16 AC 29 ms
8,944 KB
testcase_17 AC 35 ms
10,560 KB
testcase_18 AC 3 ms
5,696 KB
testcase_19 AC 68 ms
10,240 KB
testcase_20 AC 10 ms
7,716 KB
testcase_21 AC 84 ms
11,060 KB
testcase_22 AC 39 ms
10,184 KB
testcase_23 AC 29 ms
10,888 KB
testcase_24 AC 2 ms
5,508 KB
testcase_25 AC 7 ms
8,732 KB
testcase_26 AC 21 ms
9,936 KB
testcase_27 AC 38 ms
11,068 KB
testcase_28 AC 76 ms
11,048 KB
testcase_29 AC 18 ms
9,940 KB
testcase_30 AC 25 ms
9,776 KB
testcase_31 AC 8 ms
10,300 KB
testcase_32 AC 43 ms
9,492 KB
testcase_33 AC 29 ms
10,276 KB
testcase_34 AC 5 ms
8,208 KB
testcase_35 AC 11 ms
9,932 KB
testcase_36 AC 164 ms
11,348 KB
testcase_37 AC 8 ms
11,248 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