結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2016-07-08 23:31:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 453 ms |
| コンパイル使用メモリ | 51,656 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-13 07:15:11 |
| 合計ジャッジ時間 | 6,969 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 2 TLE * 1 -- * 12 |
ソースコード
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
int n;
int a[111111];
int solve(int p) {
int it = lower_bound(a+p, a+n, a[p]*2) - a;
// printf("%d %d\n", p, it);
int res = 1;
for (int i = it; i < n; i++) {
if (a[i]%a[p] == 0) {
res = max(res, solve(i)+1);
}
}
return res;
}
int main(void) {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a+i);
sort(a, a+n);
int res = 0;
for (int i = 0; i < n; i++) {
res = max(res, solve(i));
}
printf("%d\n", res);
return 0;
}
a