結果
問題 | No.390 最長の数列 |
ユーザー | togari_takamoto |
提出日時 | 2016-07-09 01:17:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 1,128 bytes |
コンパイル時間 | 1,589 ms |
コンパイル使用メモリ | 167,344 KB |
実行使用メモリ | 11,948 KB |
最終ジャッジ日時 | 2024-04-10 08:54:54 |
合計ジャッジ時間 | 2,668 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 26 ms
11,940 KB |
testcase_06 | AC | 54 ms
11,948 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 8 ms
11,096 KB |
testcase_09 | AC | 9 ms
10,992 KB |
testcase_10 | AC | 33 ms
11,908 KB |
testcase_11 | AC | 32 ms
11,908 KB |
testcase_12 | AC | 31 ms
11,768 KB |
testcase_13 | AC | 22 ms
11,708 KB |
testcase_14 | AC | 21 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 8 ms
11,044 KB |
testcase_17 | AC | 9 ms
11,172 KB |
testcase_18 | AC | 10 ms
11,192 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vvd = vector<vd>; #define REP(i,n) for(ll i = 0; i < (n); ++i) #define ALL(c) (c).begin(), (c).end() #define FOR(i,s,e) for (ll i = s; i < (ll)e; i++) #define TEN(x) ((ll)1e##x) int main() { #ifdef _WIN32 ifstream cin("sample.in"); ofstream cout("sample.out"); #endif cin.tie(0); // cinとcoutの連携を切る ios_base::sync_with_stdio(false); cout << fixed << setprecision(50); ll n; cin >> n; vl x(n); REP(i, n) cin >> x[i]; sort(ALL(x)); x.erase(unique(ALL(x)), x.end()); vb exist(x.back() + 1, false); REP(i, x.size()) exist[x[i]] = true; vl dp(x.back() + 1); REP(i, x.back() + 1) if (exist[i]) dp[i] = 1; REP(i, x.back() + 1) if(exist[i]) for (ll j = 2; i * j < x.back() + 1; j++) if(exist[i * j]) dp[i * j] = max(dp[i * j], dp[i] + 1); ll ma = 0; REP(i, x.back() + 1) ma = max(ma, dp[i]); cout << ma << endl; return 0; }