結果

問題 No.390 最長の数列
ユーザー kyo1kyo1
提出日時 2020-09-06 09:16:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 202,748 KB
実行使用メモリ 7,452 KB
最終ジャッジ日時 2023-08-19 13:32:28
合計ジャッジ時間 3,813 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 22 ms
7,188 KB
testcase_06 AC 32 ms
7,388 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 5 ms
6,916 KB
testcase_09 AC 5 ms
7,128 KB
testcase_10 AC 24 ms
7,452 KB
testcase_11 AC 23 ms
7,380 KB
testcase_12 AC 23 ms
7,428 KB
testcase_13 AC 17 ms
7,124 KB
testcase_14 AC 19 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 6 ms
6,884 KB
testcase_17 AC 6 ms
6,964 KB
testcase_18 AC 6 ms
6,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N);
  for (auto&& e : X) {
    cin >> e;
  }
  sort(X.begin(), X.end(), greater<int>());
  vector<int> T(X.front() + 1, 0);
  for (int i = 0; i < N; i++) {
    int c = 0;
    for (int j = 2 * X[i]; j < X.front() + 1; j += X[i]) {
      c = max(c, T[j]);
    }
    T[X[i]] = c + 1;
  }
  cout << *max_element(T.begin(), T.end()) << '\n';
  return 0;
}
0