結果

問題 No.390 最長の数列
ユーザー E31415926E31415926
提出日時 2016-11-06 15:35:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 1,558 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 166,484 KB
実行使用メモリ 7,888 KB
最終ジャッジ日時 2024-04-10 10:13:10
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,104 KB
testcase_01 AC 5 ms
7,100 KB
testcase_02 AC 6 ms
7,084 KB
testcase_03 AC 6 ms
7,136 KB
testcase_04 AC 6 ms
7,072 KB
testcase_05 AC 40 ms
7,752 KB
testcase_06 AC 70 ms
7,712 KB
testcase_07 AC 5 ms
7,168 KB
testcase_08 AC 6 ms
7,104 KB
testcase_09 AC 8 ms
7,148 KB
testcase_10 AC 45 ms
7,836 KB
testcase_11 AC 45 ms
7,888 KB
testcase_12 AC 44 ms
7,860 KB
testcase_13 AC 39 ms
7,716 KB
testcase_14 AC 36 ms
7,884 KB
testcase_15 AC 6 ms
7,168 KB
testcase_16 AC 6 ms
7,096 KB
testcase_17 AC 8 ms
7,224 KB
testcase_18 AC 9 ms
7,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define EXIST(s,e) (find(all(s),(e))!=(s).end())
#define exist(s,e) (find(all(s),(e))!=(s).end())
#define INF (1<<25)
#define ll long long
#define vs vector<string>
#define vi vector<int>
#define vi2 vector<vector<int>>
#define vll vector<ll>
#define vll2 vector<vector<ll>>
#define vb vector<bool>
#define v2Resize(s,x,y) s.resize(x); REP(i,s.size()) s[i].resize(y);
#define v2Fill(s,v) REP(i,s.size()) fill(all(s[i]),v);

#define V vector
#define Pii pair<int,int>
#define P pair;
#define in(x) cin>>x;
#define in1(x,m) REP(i,m){int tmp; cin>>tmp; x.push_back(tmp);}
#define in2(v2,x,y) REP(i,x) REP(j,y) cin>>v2[i][j];
#define OUT2(v2) REP(i,v2.size()){ REP(j,v2[i].size()){ cout<<v2[i][j] << " ";}cout<<endl;};
const int mod = 1000000007;
int dy4[] = {0, 0, 1, -1};
int dx4[] = {1, -1, 0, 0};
int dx8[] = {0,1,1,1,0,-1,-1,-1};
int dy8[] = {-1,-1,0,1,1,1,0,-1};

int n;
vi x;
vi dp(pow(10, 6) + 1, -INF);

int main() {
	in(n);
	in1(x, n);
	int max_x = 0;
	rep(i, n) {
		dp[x[i]] = 1;
		max_x = max(max_x, x[i]);
	}
	FOR(i,1,max_x) {
		if (dp[i] <= 0) continue;
		for (int j = i * 2; j <= max_x; j += i) {
			if (dp[j] > 0) {
				dp[j] = max(dp[j], dp[i] + 1);
			}
		}
	}
	cout << *max_element(all(dp)) << endl;
}
0