結果
問題 | No.390 最長の数列 |
ユーザー | yoma |
提出日時 | 2019-10-15 15:45:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,555 ms / 5,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 1,628 ms |
コンパイル使用メモリ | 174,832 KB |
実行使用メモリ | 12,188 KB |
最終ジャッジ日時 | 2023-08-28 14:18:05 |
合計ジャッジ時間 | 7,049 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
6,968 KB |
testcase_01 | AC | 9 ms
7,028 KB |
testcase_02 | AC | 14 ms
6,996 KB |
testcase_03 | AC | 10 ms
6,932 KB |
testcase_04 | AC | 13 ms
6,884 KB |
testcase_05 | AC | 81 ms
11,964 KB |
testcase_06 | AC | 1,555 ms
12,188 KB |
testcase_07 | AC | 6 ms
6,984 KB |
testcase_08 | AC | 5 ms
6,984 KB |
testcase_09 | AC | 10 ms
6,880 KB |
testcase_10 | AC | 302 ms
11,964 KB |
testcase_11 | AC | 311 ms
12,032 KB |
testcase_12 | AC | 286 ms
11,948 KB |
testcase_13 | AC | 419 ms
10,996 KB |
testcase_14 | AC | 544 ms
11,840 KB |
testcase_15 | AC | 4 ms
6,944 KB |
testcase_16 | AC | 5 ms
6,968 KB |
testcase_17 | AC | 9 ms
7,144 KB |
testcase_18 | AC | 14 ms
7,224 KB |
ソースコード
#include<bits/stdc++.h> #define EM 1000000 using namespace std; using LL = long long; using P = pair<LL, LL>; LL LINF = 1e18; int INF = 1e9; LL mod = 1e9+7; using vint = vector<int>; using vLL = vector<LL>; using vvint = vector<vector<int>>; using vvLL = vector<vector<LL>>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ int N; cin >> N; vector<int> x(N), cnt(1e6+1, 1); set<int> xx; for(int i = 0;i < N;i++){ cin >> x[i]; xx.insert(x[i]); } sort(x.begin(), x.end()); for(int i = 0;i < N;i++){ for(int j = 2;j*x[i] <= 1e6;j++){ auto itr = xx.find(j*x[i]); if(itr != xx.end()){ cnt[*itr] = max(cnt[*itr], cnt[x[i]]+1); } } } int ans = 0; for(auto c : cnt) ans = max(ans, c); cout << ans << endl; }