結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2016-07-09 19:33:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 69,700 KB |
実行使用メモリ | 7,612 KB |
最終ジャッジ日時 | 2024-10-02 10:46:44 |
合計ジャッジ時間 | 1,284 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> using namespace std; const int X_MAX = 1e6; int main() { int n, x; // vector<int> nums(X_MAX + 1, 0); int nums[X_MAX + 1] = {0}; // cin >> n; scanf("%d", &n); for (int i = 0; i < n; i++) { // cin >> x; scanf("%d", &x); nums[x] = 1; } int ans = 0; for (int i = X_MAX; i >= 1; i--) { if (nums[i] == 0) { continue; } for (int j = i * 2; j <= X_MAX; j += i) { nums[i] = max(nums[i], nums[j] + 1); } ans = max(ans, nums[i]); } // cout << ans << endl; printf("%d\n", ans); return 0; }