結果

問題 No.390 最長の数列
ユーザー oxyshower
提出日時 2020-01-13 19:14:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 172,248 KB
実行使用メモリ 11,912 KB
最終ジャッジ日時 2024-12-21 13:53:59
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other AC * 8 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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