結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-12 06:35:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 5,000 ms |
| コード長 | 371 bytes |
| コンパイル時間 | 474 ms |
| コンパイル使用メモリ | 63,500 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-11-27 05:17:05 |
| 合計ジャッジ時間 | 1,652 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#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;
dp[i]+=1;
for(int j=i+i;j<1<<20;j+=i)
{
dp[j]=max(dp[j],dp[i]);
}
ans=max(ans,dp[i]);
}
cout<<ans<<endl;
}