結果
| 問題 |
No.2218 Multiple LIS
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-04-23 16:59:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 3,000 ms |
| コード長 | 767 bytes |
| コンパイル時間 | 260 ms |
| コンパイル使用メモリ | 41,928 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 23:48:10 |
| 合計ジャッジ時間 | 3,304 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2218.cc: No.2218 Multiple LIS - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
const int MAX_A = 100000;
/* typedef */
/* global variables */
int as[MAX_N], dp[MAX_A + 1];
/* subroutines */
inline void setmax(int &a, int b) { if (a < b) a = b; }
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = n - 1; i >= 0; i--) {
int ai = as[i];
dp[ai]++;
for (int p = 2; p * p <= ai; p++)
if (ai % p == 0) {
int q = ai / p;
setmax(dp[p], dp[ai]);
setmax(dp[q], dp[ai]);
}
setmax(dp[1], dp[ai]);
}
printf("%d\n", *max_element(dp, dp + MAX_A + 1));
return 0;
}
tnakao0123