結果
問題 | No.390 最長の数列 |
ユーザー | rodea |
提出日時 | 2021-01-11 17:21:30 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,113 ms / 5,000 ms |
コード長 | 1,653 bytes |
コンパイル時間 | 1,576 ms |
コンパイル使用メモリ | 117,684 KB |
実行使用メモリ | 7,516 KB |
最終ジャッジ日時 | 2023-08-13 13:39:11 |
合計ジャッジ時間 | 7,918 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,888 KB |
testcase_01 | AC | 4 ms
6,900 KB |
testcase_02 | AC | 3 ms
6,988 KB |
testcase_03 | AC | 5 ms
6,940 KB |
testcase_04 | AC | 4 ms
6,916 KB |
testcase_05 | AC | 1,113 ms
7,516 KB |
testcase_06 | AC | 711 ms
7,440 KB |
testcase_07 | AC | 4 ms
6,960 KB |
testcase_08 | AC | 4 ms
6,976 KB |
testcase_09 | AC | 4 ms
6,928 KB |
testcase_10 | AC | 783 ms
7,392 KB |
testcase_11 | AC | 785 ms
7,452 KB |
testcase_12 | AC | 782 ms
7,424 KB |
testcase_13 | AC | 568 ms
7,208 KB |
testcase_14 | AC | 279 ms
7,448 KB |
testcase_15 | AC | 4 ms
6,924 KB |
testcase_16 | AC | 5 ms
6,996 KB |
testcase_17 | AC | 39 ms
6,928 KB |
testcase_18 | AC | 62 ms
6,936 KB |
ソースコード
#pragma GCC optimize("O3") #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <fstream> #include <functional> #include <bitset> using namespace std; using ll = long long; using P = pair<int, int>; using T = tuple<int, int, int>; template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;} template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;} constexpr int MOD = 1e9 + 7; constexpr int inf = 1e9; constexpr long long INF = 1e18; #define all(a) (a).begin(), (a).end() int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; vector<ll> divisor(ll n){ vector<ll> v; for(ll i=1; i*i<=n; i++){ if(n % i == 0){ v.emplace_back(i); v.emplace_back(n / i); } } sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); return v; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; vector<int> x(n); for(int i=0; i<n; i++) cin>>x[i]; sort(all(x)); vector<int> dp(1000010, 0); dp[1] = 0; for(int i=0; i<n; i++){ auto div = divisor(x[i]); int ma = 0; for(auto j:div){ chmax(ma, dp[j]); } dp[x[i]] = ma + 1; } cout << *max_element(all(dp)) << endl; return 0; }