結果

問題 No.390 最長の数列
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 06:33:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 372 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 63,460 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-08-18 02:58:18
合計ジャッジ時間 3,851 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 372 ms
4,376 KB
testcase_06 AC 256 ms
8,340 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 276 ms
8,272 KB
testcase_11 AC 275 ms
8,284 KB
testcase_12 AC 274 ms
8,228 KB
testcase_13 AC 203 ms
8,284 KB
testcase_14 AC 108 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 19 ms
8,224 KB
testcase_18 AC 27 ms
8,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int dp[1<<20];
bool exs[1<<20];
int ans;
int max(int a,int b){return a<b?b:a;}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int s;cin>>s;exs[s]=1;
	}
	for(int i=1;i<1<<20;i++)
	{
		if(!exs[i])continue;
		for(int j=1;j*j<=i;j++)
		{
			if(i%j==0)
			{
				dp[i]=max(dp[i],max(dp[j],dp[i/j])+1);
			}
		}
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}
0