結果

問題 No.1703 Much Matching
ユーザー kotatsugamekotatsugame
提出日時 2021-10-08 22:08:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 67,524 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-09-30 10:23:16
合計ジャッジ時間 4,275 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,352 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 5 ms
7,572 KB
testcase_04 AC 4 ms
7,420 KB
testcase_05 AC 7 ms
7,724 KB
testcase_06 AC 96 ms
7,404 KB
testcase_07 AC 10 ms
7,988 KB
testcase_08 AC 106 ms
8,000 KB
testcase_09 AC 119 ms
8,068 KB
testcase_10 AC 18 ms
6,084 KB
testcase_11 AC 30 ms
7,908 KB
testcase_12 AC 7 ms
5,980 KB
testcase_13 AC 51 ms
7,956 KB
testcase_14 AC 3 ms
5,516 KB
testcase_15 AC 26 ms
8,048 KB
testcase_16 AC 64 ms
6,868 KB
testcase_17 AC 75 ms
8,216 KB
testcase_18 AC 3 ms
5,456 KB
testcase_19 AC 154 ms
8,220 KB
testcase_20 AC 20 ms
5,604 KB
testcase_21 AC 181 ms
8,148 KB
testcase_22 AC 76 ms
7,876 KB
testcase_23 AC 57 ms
8,100 KB
testcase_24 AC 3 ms
5,552 KB
testcase_25 AC 10 ms
6,740 KB
testcase_26 AC 39 ms
7,956 KB
testcase_27 AC 82 ms
8,256 KB
testcase_28 AC 156 ms
8,372 KB
testcase_29 AC 33 ms
7,988 KB
testcase_30 AC 46 ms
7,836 KB
testcase_31 AC 8 ms
7,928 KB
testcase_32 AC 85 ms
7,840 KB
testcase_33 AC 56 ms
8,256 KB
testcase_34 AC 7 ms
6,000 KB
testcase_35 AC 19 ms
7,844 KB
testcase_36 AC 346 ms
8,312 KB
testcase_37 AC 8 ms
8,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,M,Q;
bool G[1000][1000];
int dp[1000][1000];
main()
{
	cin>>N>>M>>Q;
	for(int i=0;i<Q;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a][b]=true;
	}
	int ans=0;
	for(int i=0;i<N;i++)for(int j=0;j<M;j++)
	{
		ans=max(ans,dp[i][j]+G[i][j]);
		if(i+1<N)dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
		if(j+1<M)dp[i][j+1]=max(dp[i][j+1],dp[i][j]);
		if(G[i][j])
		{
			if(i+1<N&&j+1<M)dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
		}
	}
	cout<<ans<<endl;
}
0