結果

問題 No.1515 Making Many Multiples
ユーザー kotatsugamekotatsugame
提出日時 2021-05-21 21:50:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 68,996 KB
実行使用メモリ 19,292 KB
最終ジャッジ日時 2024-04-18 15:06:20
合計ジャッジ時間 3,527 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 150 ms
19,116 KB
testcase_03 AC 143 ms
19,292 KB
testcase_04 AC 153 ms
19,196 KB
testcase_05 AC 167 ms
19,192 KB
testcase_06 AC 108 ms
19,200 KB
testcase_07 AC 119 ms
19,224 KB
testcase_08 AC 34 ms
12,976 KB
testcase_09 AC 68 ms
14,300 KB
testcase_10 AC 72 ms
15,292 KB
testcase_11 AC 92 ms
17,044 KB
testcase_12 AC 57 ms
14,144 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 102 ms
17,576 KB
testcase_15 AC 5 ms
6,940 KB
testcase_16 AC 154 ms
18,576 KB
testcase_17 AC 22 ms
15,144 KB
testcase_18 AC 18 ms
17,584 KB
testcase_19 AC 7 ms
12,816 KB
testcase_20 AC 21 ms
12,048 KB
testcase_21 AC 84 ms
19,080 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 92 ms
18,900 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 118 ms
19,136 KB
testcase_28 AC 67 ms
19,092 KB
testcase_29 AC 5 ms
8,296 KB
testcase_30 AC 8 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,K,X,Y;
int dp[2000][2000];
int mH[2000],mW[2000];
main()
{
	cin>>N>>K>>X>>Y;
	X%=K;
	Y%=K;
	for(int i=0;i<K;i++)for(int j=0;j<K;j++)dp[i][j]=-1e9;
	for(int i=0;i<K;i++)mH[i]=mW[i]=-1e9;
	dp[X][Y]=0;
	mH[X]=0;
	mW[Y]=0;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;A%=K;
		for(int h=0;h<K;h++)
		{
			int w=(K+K-A-h)%K;
			dp[h][w]++;
			mH[h]=max(mH[h],dp[h][w]);
			mW[w]=max(mW[w],dp[h][w]);
		}
		for(int h=0;h<K;h++)dp[h][A]=mH[h];
		for(int w=0;w<K;w++)dp[A][w]=mW[w];
		for(int h=0;h<K;h++)mW[A]=max(mW[A],dp[h][A]);
		for(int w=0;w<K;w++)mH[A]=max(mH[A],dp[A][w]);
	}
	int ans=0;
	for(int i=0;i<K;i++)ans=max(ans,max(mH[i],mW[i]));
	cout<<ans<<endl;
}
0