結果

問題 No.390 最長の数列
ユーザー RIGIHRIGIH
提出日時 2017-07-26 13:54:57
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 894 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 65,072 KB
実行使用メモリ 10,784 KB
最終ジャッジ日時 2024-04-18 00:00:38
合計ジャッジ時間 7,138 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 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 <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define mass 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
void sort(int *x,int);


int main(){
	
	int n;
	cin>>n;
	int *x;
	x=new int[n];
	int *a;
	a=new int[n];
	rep(i,n){
		cin>>x[i];
		a[i]=1;
	}
	if(n>=2) sort(x,n);
	int ans=0;

	rep(i,n){
		rep(j,i){
			if(x[j]%x[i]==0){
				a[i]=max(a[i],a[j]+1);
			}
		}
		ans=max(ans,a[i]);
	}
	cout<<ans<<endl;
	delete []x;
	delete []a;
	return 0;


}

void sort(int *x,int n){
	int a;
	rep(i,n){
		int j=n-1;
		while(j>i){
			if(x[j]>x[j-1]){
				a=x[j-1];x[j-1]=x[j];x[j]=a;
			}
			j--;
		}
	}
}
0