結果

問題 No.390 最長の数列
ユーザー oxyshoweroxyshower
提出日時 2020-01-13 19:12:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 170,092 KB
実行使用メモリ 11,920 KB
最終ジャッジ日時 2023-08-23 11:19:55
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
10,868 KB
testcase_01 AC 8 ms
10,696 KB
testcase_02 AC 9 ms
10,884 KB
testcase_03 AC 8 ms
10,736 KB
testcase_04 AC 8 ms
10,864 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 6 ms
10,968 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 46 ms
11,640 KB
testcase_11 WA -
testcase_12 AC 46 ms
11,596 KB
testcase_13 AC 39 ms
11,572 KB
testcase_14 AC 79 ms
11,520 KB
testcase_15 AC 5 ms
10,732 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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++){
    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