結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
misora192
|
| 提出日時 | 2020-06-18 08:31:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 1,795 ms |
| コンパイル使用メモリ | 172,644 KB |
| 実行使用メモリ | 7,672 KB |
| 最終ジャッジ日時 | 2024-07-03 12:41:15 |
| 合計ジャッジ時間 | 3,427 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> x(n);
rep(i, n) cin >> x[i];
sort(x.begin(), x.end());
int max_x = 1010101;
vector<int> dp(max_x, 1);
rep(i, n){
int y = x[i];
for(int j = 2 * y; j < max_x; j += y) chmax(dp[j], dp[y] + 1);
}
int ans = 0;
rep(i, n) chmax(ans, dp[x[i]]);
cout << ans << endl;
}
misora192