結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
Im_Gimlet
|
| 提出日時 | 2020-09-05 13:28:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 5,000 ms |
| コード長 | 899 bytes |
| コンパイル時間 | 1,698 ms |
| コンパイル使用メモリ | 172,448 KB |
| 実行使用メモリ | 7,620 KB |
| 最終ジャッジ日時 | 2024-11-28 04:32:08 |
| 合計ジャッジ時間 | 2,977 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }
int n;
int main() {
cin >> n;
vector<int> xvec(n, 0);
for(int i = 0; i < n ; ++i) cin >> xvec[i];
sort(xvec.begin(), xvec.end());
vector<int> dp(1000100, 0);
for(int i = 0; i < n; ++i) {
int ch = xvec[i];
int now = dp[ch]+1;
while(ch <= 1000000) {
chmax(dp[ch], now);
ch += xvec[i];
}
}
int ans = 0;
for(int i = 0; i < n; ++i) chmax(ans, dp[xvec[i]]);
cout << ans << endl;
}
Im_Gimlet