結果

問題 No.390 最長の数列
ユーザー amtgjwamtgjw
提出日時 2018-05-31 17:24:29
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 901 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 69,592 KB
実行使用メモリ 8,080 KB
最終ジャッジ日時 2023-09-12 20:59:49
合計ジャッジ時間 9,606 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MINF		-200000007
#define MOD			1048576 	
// 2^20

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int dp[MAX];

int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];
	int upper = A[N-1];

	sort(A.begin(),A.end());
	fill(dp,dp+upper,MINF);

	// << "max : " << upper << endl;
	int maxl = 0;
	REP(i,N){
		int X = A[i];
		if(dp[X] < 0) dp[X]=1;
		for(int j=i-1;j>=0;--j){
			int Y = A[j];
			if (X%Y != 0) continue;
			//cout << X << ":" << Y << "[" << dp[Y] << "]" << endl;
			dp[X] = max(dp[X],dp[Y]+1);
		}
	}
	REP(i,N) maxl = max(maxl,dp[A[i]]);

	cout << maxl << endl;

	return 0;
}
0