結果

問題 No.390 最長の数列
ユーザー ei1333333ei1333333
提出日時 2016-07-08 22:37:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 359 ms / 5,000 ms
コード長 423 bytes
コンパイル時間 1,219 ms
コンパイル使用メモリ 160,628 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-10 08:46:07
合計ジャッジ時間 3,749 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 359 ms
6,944 KB
testcase_06 AC 235 ms
7,936 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 262 ms
7,884 KB
testcase_11 AC 263 ms
7,936 KB
testcase_12 AC 263 ms
7,936 KB
testcase_13 AC 188 ms
7,808 KB
testcase_14 AC 99 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 16 ms
7,552 KB
testcase_18 AC 25 ms
7,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     scanf("%d", &X[i]);
      |     ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int N, X[100000];
int dp[1000001];

int main()
{  
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &X[i]);
  }
  sort(X, X + N);
  for(int i = 0; i < N; i++) {
    for(int j = 1; j * j <= X[i]; j++) {
      if(X[i] % j == 0) {
        dp[X[i]] = max(dp[X[i]], max(dp[j], dp[X[i] / j]) + 1);
      }
    }
  }
  printf("%d", *max_element(dp, dp + 1000001));
}
0