結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-21 17:55:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 820 bytes |
| コンパイル時間 | 1,085 ms |
| コンパイル使用メモリ | 85,200 KB |
| 最終ジャッジ日時 | 2024-11-14 21:35:47 |
| 合計ジャッジ時間 | 1,718 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:21:17: error: variable 'std::array<int, 1000001> dp' has initializer but incomplete type
21 | array<int, M+1> dp{};
| ^~
ソースコード
#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
constexpr int M = 1000000;
array<int, M+1> dp{};
int main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int x; scanf("%d", &x);
dp[x] = 1;
}
for (int i = 1; i <= M; ++i) {
if(!dp[i]) continue;
for (int j = i*2; j <= M; j += i) {
if(!dp[j]) continue;
dp[j] = max(dp[j], dp[i]+1);
}
}
cout << *max_element(dp.begin(),dp.end()) << "\n";
return 0;
}