結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2016-07-08 23:05:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 622 bytes |
| コンパイル時間 | 682 ms |
| コンパイル使用メモリ | 69,596 KB |
| 実行使用メモリ | 8,680 KB |
| 最終ジャッジ日時 | 2024-10-13 06:30:36 |
| 合計ジャッジ時間 | 1,711 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 WA * 3 |
ソースコード
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
bool exist[1000010];
int dp[1000010];
int x[100000];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
for(int i = 0; i < N; i++) {
cin >> x[i];
exist[x[i]] = true;
}
sort(x, x + N);
int M = x[N - 1];
fill(dp, dp + 1000010, 1);
for(int i = 0; i < N; i++) {
for(int j = 2; x[i] * j <= M; j++) {
if(exist[x[i] * j]) {
dp[x[i] * j] = max(dp[x[i] * j], dp[x[i]] + 1);
break;
}
}
}
cout << *max_element(dp, dp + 1000010) << endl;
}
femto