結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2020-06-02 18:41:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 77 ms / 5,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 1,390 ms |
コンパイル使用メモリ | 162,164 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-11-24 06:52:36 |
合計ジャッジ時間 | 2,859 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.02 18:41:05 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n;cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); vector<int> b(1000000,-1); for (int i = 0; i < n; i++) { b[a[i]-1] = i; } vector<int> c(n,1); int ans = 1; for (int i = 0; i < 1000000; i++) { if (b[i] == -1) continue; for (int j = 2 * i + 2; j <= 1000000; j += i + 1) { if (b[j-1] == -1) continue; c[b[j-1]] = max(c[b[j-1]],c[b[i]] + 1); ans = max(ans,c[b[j-1]]); } } cout << ans << endl; return 0; }