結果

問題 No.390 最長の数列
ユーザー E31415926E31415926
提出日時 2016-11-06 15:19:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,556 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 168,028 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-16 13:59:44
合計ジャッジ時間 5,067 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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((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