結果

問題 No.390 最長の数列
ユーザー vjudge1
提出日時 2025-04-18 16:31:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 162,840 KB
実行使用メモリ 15,108 KB
最終ジャッジ日時 2025-04-18 16:31:59
合計ジャッジ時間 8,474 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other WA * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
int const N=1e6+5;
int n,m,sum,cnt,t,ans,a[N];
int c[N];
bool p[N];
signed main()
{
//	freopen("sequence.in","r",stdin);
//	freopen("sequence.out","r",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
	sort(a+1,a+1+n);
    for(int i=1;i<n;i++)
    {
    	int p=1;
    	int lst=a[i];
    	for(int j=i+1;j<=n;j++)
    	{
    		
    		if(a[j]%lst==0)
    		{
    			p++;
				c[j]=p;
    			lst=a[j];
			}
		}
		ans=max(p,ans);
	}
	for(int i=1;i>=n;i++)
	{
		ans=max(ans,c[i]);
	}
	cout<<ans;
	return 0;
}
0