結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2017-01-01 01:48:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 499 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 60,476 KB |
実行使用メモリ | 13,764 KB |
最終ジャッジ日時 | 2024-12-16 04:46:24 |
合計ジャッジ時間 | 43,590 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 3 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=1; 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; }