結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2016-09-11 19:06:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 590 bytes |
コンパイル時間 | 1,016 ms |
コンパイル使用メモリ | 74,496 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-17 03:36:47 |
合計ジャッジ時間 | 21,881 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 3 TLE * 2 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> void run(std::vector<int>&xs, std::vector<int>&xs_dp,int index,int cost) { for (unsigned int i = index+1; i < xs.size(); i++) { if (xs[i] % xs[index] == 0&&xs_dp[i]<cost+1) { xs_dp[i] = cost+1; run(xs, xs_dp, i,cost+1); } } } int main() { int n; std::cin >> n; std::vector<int> xs(n); std::vector<int> xs_dp(n); for (int i = 0; i < n; i++) { std::cin >> xs[i]; xs_dp[i] = 1; } std::sort(xs.begin(), xs.end()); run(xs, xs_dp, 0, 1); std::cout << *std::max_element(xs_dp.begin(), xs_dp.end())<<std::endl; }