結果

問題 No.390 最長の数列
ユーザー aa
提出日時 2016-07-08 23:31:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 559 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 52,936 KB
実行使用メモリ 10,656 KB
最終ジャッジ日時 2024-04-21 08:25:39
合計ジャッジ時間 6,954 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 23 ms
5,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int n;
int a[111111];

int solve(int p) {
  int it = lower_bound(a+p, a+n, a[p]*2) - a;
  // printf("%d %d\n", p, it);
  int res = 1;
  for (int i = it; i < n; i++) {
    if (a[i]%a[p] == 0) {
      res = max(res, solve(i)+1);
    }
  }
  return res;
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a+i);

  sort(a, a+n);

  int res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, solve(i));
  }

  printf("%d\n", res);
  return 0;
}
0