結果

問題 No.1703 Much Matching
ユーザー Drice27149Drice27149
提出日時 2021-10-08 22:45:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 41,664 KB
実行使用メモリ 10,908 KB
最終ジャッジ日時 2023-09-30 11:48:03
合計ジャッジ時間 3,243 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,084 KB
testcase_01 AC 2 ms
5,092 KB
testcase_02 AC 2 ms
5,036 KB
testcase_03 AC 3 ms
7,256 KB
testcase_04 AC 4 ms
8,060 KB
testcase_05 AC 5 ms
8,252 KB
testcase_06 AC 51 ms
8,632 KB
testcase_07 AC 6 ms
9,984 KB
testcase_08 AC 63 ms
9,880 KB
testcase_09 AC 67 ms
10,088 KB
testcase_10 AC 10 ms
7,840 KB
testcase_11 AC 17 ms
9,652 KB
testcase_12 AC 4 ms
7,512 KB
testcase_13 AC 26 ms
9,404 KB
testcase_14 AC 3 ms
7,296 KB
testcase_15 AC 16 ms
10,108 KB
testcase_16 AC 33 ms
8,480 KB
testcase_17 AC 40 ms
10,248 KB
testcase_18 AC 3 ms
5,152 KB
testcase_19 AC 82 ms
9,712 KB
testcase_20 AC 11 ms
7,336 KB
testcase_21 AC 98 ms
10,548 KB
testcase_22 AC 43 ms
9,672 KB
testcase_23 AC 31 ms
10,416 KB
testcase_24 AC 3 ms
5,208 KB
testcase_25 AC 7 ms
8,300 KB
testcase_26 AC 23 ms
9,504 KB
testcase_27 AC 43 ms
10,672 KB
testcase_28 AC 93 ms
10,760 KB
testcase_29 AC 18 ms
9,540 KB
testcase_30 AC 25 ms
9,408 KB
testcase_31 AC 7 ms
9,808 KB
testcase_32 AC 45 ms
9,132 KB
testcase_33 AC 34 ms
9,892 KB
testcase_34 AC 5 ms
7,740 KB
testcase_35 AC 11 ms
9,548 KB
testcase_36 AC 201 ms
10,840 KB
testcase_37 AC 7 ms
10,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
int f[1005][1005];
int edge[1005][1005];

int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for(int i = 0; i < q; i++){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u][v] = 1;
	}
	f[0][0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= m; j++){
			f[i][j] = f[i-1][j];
			if(j){
				f[i][j] = std::max(f[i][j], f[i][j-1]);
				if(edge[i][j]){
					f[i][j] = std::max(f[i][j], f[i-1][j-1]+1);
				}
			}
			//printf("f[%d][%d] = %d\n",i,j,f[i][j]);
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}
0