結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-31 14:11:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 515 bytes |
| コンパイル時間 | 582 ms |
| コンパイル使用メモリ | 60,672 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-12-16 04:29:47 |
| 合計ジャッジ時間 | 44,043 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 5 TLE * 7 |
ソースコード
#include <iostream>
#include <stdio.h>
#include <algorithm>
int main()
{
int N; std::cin >> N;
int *x = new int[N];
int *dp = new int[N];
for(int i=0;i<N;i++)
{
std::cin >> x[i];
}
std::sort(x , x+N);
dp[0] = 1;
int M = 0;
for(int i=1;i<N;i++)
{
int max = 1;
for(int j=i-1 ; j>=0 ; --j)
{
int l = ((x[i]%x[j]==0 && x[i]>x[j]) ? dp[j]+1 : dp[j]);
if(l > max) max = l;
}
dp[i] = max;
if(M < dp[i]) M = dp[i];
}
std::cout << M << std::endl;
delete[] x;
delete[] dp;
return 0;
}