結果

問題 No.390 最長の数列
ユーザー oxyshoweroxyshower
提出日時 2019-03-03 00:35:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 170,268 KB
実行使用メモリ 11,828 KB
最終ジャッジ日時 2023-09-05 17:36:34
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 8 ms
10,816 KB
testcase_04 WA -
testcase_05 AC 23 ms
11,516 KB
testcase_06 WA -
testcase_07 AC 6 ms
10,840 KB
testcase_08 AC 5 ms
10,908 KB
testcase_09 AC 6 ms
10,772 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 23 ms
11,632 KB
testcase_14 WA -
testcase_15 AC 5 ms
10,856 KB
testcase_16 AC 5 ms
10,836 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
  }
  sort(x.rbegin(),x.rend());

  vector<int> dp(1000000+1,0);
  for(int i : x){
    dp[i] = max(dp[i],1LL);
    for(int j = i*2; j <= 1000000; j+=i){
      dp[j] = max(dp[j],dp[i]+1);
    }
  }

  int ans = 0;
  for(int i : x){
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;

  return 0;
}
0