結果

問題 No.390 最長の数列
ユーザー oxyshoweroxyshower
提出日時 2020-01-13 19:14:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 170,612 KB
実行使用メモリ 11,764 KB
最終ジャッジ日時 2023-08-23 11:22:39
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
11,472 KB
testcase_06 AC 64 ms
11,616 KB
testcase_07 WA -
testcase_08 AC 6 ms
10,964 KB
testcase_09 AC 7 ms
10,836 KB
testcase_10 WA -
testcase_11 AC 47 ms
11,608 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 6 ms
10,800 KB
testcase_17 AC 7 ms
10,764 KB
testcase_18 AC 8 ms
11,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  vector<int> v(1000001, 0);
  for(int i = 0; i < n; i++){
    v[a[i]] = max(v[a[i]], 1LL);
    for(int j = a[i] * 2; j < 1000001; j+=a[i]){
      v[j] = max(v[j], v[a[i]] + 1);
    }
  }
  cout << *max_element(v.begin(),v.end()) << endl;

  return 0;
}
0