結果

問題 No.390 最長の数列
ユーザー itezpaceitezpace
提出日時 2016-07-09 00:39:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 526 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 163,188 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-21 09:01:30
合計ジャッジ時間 8,329 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> v;
int m;

void rec(int i, int c){
  if(i==0){
    return;
  }
  for(int j=i-1; j>=0; --j){
    if(v[i]%v[j]==0){
      int d;
      d=c;
      d++;
      if(d>m){
        m=d;
      }
      rec(j,d);
    }
  }
}

int main(){
  int n,x;
  cin>>n;
  for(int i=0; i<n; ++i){
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(),v.end());
  m=1;
  int c;
  for(int i=v.size()-1; i>0; --i){
    c=1;
    rec(i,c);
  }
  cout<<m<<endl;
  return 0;
}
0