結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2017-09-10 10:33:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 1,128 ms |
コンパイル使用メモリ | 96,176 KB |
実行使用メモリ | 16,896 KB |
最終ジャッジ日時 | 2024-11-07 12:32:47 |
合計ジャッジ時間 | 8,029 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 13 |
ソースコード
#include <cmath> #include <vector> #include <list> #include <map> #include <set> #include <functional> #include <queue> #include <iostream> #include <string.h> #include <iomanip> #include <algorithm> #include <functional> #include <cstdint> #include <climits> #include <unordered_set> #include <sstream> #include <stack> using namespace std; typedef long long int ll; typedef tuple<int,int,int> t3; using namespace std; int vs[1000100]; int l[1000100]; int dp[1000100]; vector<int> t; void solve() { int n; cin >> n; fill(vs, vs + 1000100, -1); fill(l, l + 1000100, -1); t.resize(n); for(int i = 0;i < n;i++) { int a; cin >> a; vs[a] = i; t[i] = a; } sort(t.begin(), t.end()); int m = 1; for(int i = n-1;i >= 0;i--) { dp[t[i]] = 1; for(int j = i +1;j < n;j++) { if(t[j] % t[i] == 0) { dp[t[i]] = max(dp[t[i]], 1 + dp[t[j]]); m = max(m, dp[t[i]]); } } } cout << m << endl; } int main() { solve(); return 0; }