結果

問題 No.1703 Much Matching
ユーザー abc3abc3
提出日時 2021-10-12 21:28:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 1,302 bytes
コンパイル時間 3,993 ms
コンパイル使用メモリ 205,652 KB
実行使用メモリ 11,116 KB
最終ジャッジ日時 2023-10-17 10:23:36
合計ジャッジ時間 8,356 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 4 ms
5,308 KB
testcase_04 AC 4 ms
4,780 KB
testcase_05 AC 6 ms
7,684 KB
testcase_06 AC 45 ms
6,364 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 54 ms
9,004 KB
testcase_09 AC 57 ms
7,420 KB
testcase_10 AC 10 ms
4,516 KB
testcase_11 AC 16 ms
6,100 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 24 ms
5,572 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 15 ms
7,948 KB
testcase_16 AC 29 ms
4,780 KB
testcase_17 AC 34 ms
5,308 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 69 ms
6,892 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 84 ms
7,948 KB
testcase_22 AC 38 ms
8,212 KB
testcase_23 AC 27 ms
5,836 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 6 ms
4,516 KB
testcase_26 AC 23 ms
8,212 KB
testcase_27 AC 36 ms
5,308 KB
testcase_28 AC 79 ms
9,796 KB
testcase_29 AC 18 ms
6,628 KB
testcase_30 AC 23 ms
6,364 KB
testcase_31 AC 5 ms
4,780 KB
testcase_32 AC 41 ms
7,420 KB
testcase_33 AC 30 ms
8,476 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 9 ms
4,516 KB
testcase_36 AC 171 ms
11,116 KB
testcase_37 AC 10 ms
11,116 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<ll,ll>;
    const ll INF=1e18;
    const int mod=1e9+7;
    
    void solve(){
        int n,m,q;
        cin>>n>>m>>q;
        vector<vector<int>>t(n+1,vector<int>(m+1));
        rep(i,q){
            int a,b;
            cin>>a>>b;
            t[a][b]=1;
        }
        vector<vector<int>>dp(n+1,vector<int>(m+1));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(t[i][j]){
                    chmax(dp[i][j],dp[i-1][j-1]+1);
                }
                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