結果

問題 No.390 最長の数列
ユーザー tkmst201tkmst201
提出日時 2017-04-07 22:05:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 899 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 146,440 KB
実行使用メモリ 8,008 KB
最終ジャッジ日時 2023-09-23 00:08:07
合計ジャッジ時間 2,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,460 KB
testcase_01 AC 8 ms
7,444 KB
testcase_02 AC 8 ms
7,524 KB
testcase_03 AC 8 ms
7,384 KB
testcase_04 AC 9 ms
7,400 KB
testcase_05 AC 21 ms
6,164 KB
testcase_06 AC 42 ms
7,788 KB
testcase_07 AC 7 ms
7,520 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 7 ms
7,400 KB
testcase_10 AC 31 ms
7,784 KB
testcase_11 AC 30 ms
7,700 KB
testcase_12 AC 30 ms
8,008 KB
testcase_13 AC 23 ms
7,628 KB
testcase_14 AC 55 ms
7,872 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int dp[1123456];
int n;
int x[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", x + i);
	sort(x, x + n);
	
	dp[x[0]] = 1;
	REP(i, n) {
		for (int j = 2; j <= 1000000; j++) {
			if ((ll)x[i] * j > 1000000) break;
			chmax(dp[x[i] * j], dp[x[i]] + 1);
		}
	}
	
	int ans = 0;
	REP(i, n) chmax(ans, dp[x[i]]);
	cout << ans << endl;
	
	return 0;
}
0