結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-01 01:04:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 501 bytes |
| コンパイル時間 | 558 ms |
| コンパイル使用メモリ | 59,348 KB |
| 実行使用メモリ | 12,068 KB |
| 最終ジャッジ日時 | 2024-12-16 04:38:34 |
| 合計ジャッジ時間 | 43,608 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| 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>=max ; --j)
{
int l=0;
if(x[i]%x[j]==0) l = dp[j]+1;
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;
}