結果

問題 No.390 最長の数列
ユーザー rickythetarickytheta
提出日時 2016-07-09 10:39:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 816 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 48,256 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-10 08:56:30
合計ジャッジ時間 1,519 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,816 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 7 ms
6,940 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 7 ms
6,940 KB
testcase_05 AC 21 ms
6,944 KB
testcase_06 AC 63 ms
7,552 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 29 ms
7,424 KB
testcase_11 AC 31 ms
7,424 KB
testcase_12 AC 33 ms
7,424 KB
testcase_13 AC 23 ms
7,424 KB
testcase_14 AC 55 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 7 ms
7,040 KB
testcase_18 AC 6 ms
7,040 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |     scanf("%d",x+i);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

// #include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

int n;
int x[125252];
int dp[1<<20];

int main(){
  vector<bool> has(1<<20,false);
  int ans = 1;

  scanf("%d",&n);
  REP(i,n){
    scanf("%d",x+i);
    has[x[i]] = true;
  }
  sort(x,x+n,greater<int>());
  REP(i,n){
    int y = x[i];
    int it = y;
    if(dp[y]==0)dp[y]=1;
    for(int it=2*y;it<(1<<20);it+=y){
      if(!has[it])continue;
      if(dp[y]<=dp[it])dp[y]=dp[it]+1;
    }
    if(ans<dp[y])ans=dp[y];
  }
  printf("%d\n",ans);
  return 0;
}
0