結果

問題 No.979 Longest Divisor Sequence
ユーザー simansiman
提出日時 2023-01-11 10:38:56
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 4,216 ms
コンパイル使用メモリ 105,244 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-08-23 18:18:23
合計ジャッジ時間 4,198 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
4,996 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 4 ms
4,948 KB
testcase_13 WA -
testcase_14 AC 99 ms
6,040 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int A[N];

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  int counter[300010];
  memset(counter, 0, sizeof(counter));
  bool checked[300010];
  memset(checked, false, sizeof(checked));
  int ans = 1;

  for (int i = 0; i <= 300000; ++i) {
    counter[i] = 1;
  }

  for (int i = 0; i < N; ++i) {
    int a = A[i];
    if (checked[a]) continue;
    checked[a] = true;

    int j = 2;
    while (a * j <= 300000) {
      int v = a * j;
      counter[v] = max(counter[v], counter[a] + 1);
      ans = max(ans, counter[v]);

      j += 1;
    }
  }

  cout << ans << endl;

  return 0;
}
0