結果
問題 | No.2218 Multiple LIS |
ユーザー |
![]() |
提出日時 | 2023-02-24 19:09:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,074 bytes |
コンパイル時間 | 3,877 ms |
コンパイル使用メモリ | 256,520 KB |
最終ジャッジ日時 | 2025-02-10 20:17:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 TLE * 8 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; using ll=int; using ld=double; ld pie=3.14159265359; ll mod=998244353; ll inf=100000; int main(){ ll n; cin >> n; vector<ll>a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } map<ll,ll>memo; for (ll i = 0; i < n; i++) { bool ok=false; ll now=1; vector<ll>kesu; for(auto v:memo){ if (a[i]%v.first==0) { now=max(now,v.second+1); } if (v.first%a[i]==0) { if (now>=v.second) { kesu.push_back(v.first); } } } if (!kesu.empty()) { for (ll j = 0; j < kesu.size(); j++) { memo.erase(kesu[j]); } memo[a[i]]=now; }else{ memo[a[i]]=now; } } ll ans=0; for(auto v:memo){ ans=max(ans,v.second); } cout << ans << endl; }