結果
問題 | No.390 最長の数列 |
ユーザー |
![]() |
提出日時 | 2025-04-18 16:48:21 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,845 ms / 5,000 ms |
コード長 | 2,080 bytes |
コンパイル時間 | 6,668 ms |
コンパイル使用メモリ | 477,852 KB |
実行使用メモリ | 74,284 KB |
最終ジャッジ日時 | 2025-04-18 16:48:37 |
合計ジャッジ時間 | 14,638 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include<bits/stdc++.h> #define int long long #define MAXN 100005 using namespace std; inline int read(){ int x=0; char c=getchar(); while(c<'0' || c>'9'){ c=getchar(); } while(c>='0' && c<='9'){ x=(x<<1)+(x<<3)+(c^48); c=getchar(); } return x; } int n,maxn=0,res=1; int a[MAXN]; vector<int> dp(1e6+5,1); map<int,int> mp; signed main(){ // freopen("sequence.in","r",stdin); // freopen("sequence.out","w",stdout); n=read(); for(int i=1;i<=n;i++){ a[i]=read(); mp[a[i]]=1; maxn=max(maxn,a[i]); } sort(a+1,a+n+1); for(int i=1;i<=n;i++){ int x=a[i]; for(int k=2;x*k<=maxn;k++){ int j=x*k; if(mp[j]){ dp[j]=max(dp[j],dp[x]+1); res=max(res,dp[j]); } } } printf("%lld\n",res); return 0; } /*?? ?????? ??????????????????????? ???????????????????? ???????????5???????????????????????????????????????????????????????????????????????????????????????????????24????????????????????????????????????????????????????????????????????? ???????????????????? ???????????????????????????????????????????????????????????????????????????????????????????...????????????? ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...???????????????????????????????? ?????????????? ???????????? ????????????? ????????????? ????????? ??? ? ?? ? ??????? ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????? ????????????????????? ???????????????????? ????????????? ???????????????? ???????????????????????? ????????????????????????? ?????? ?????????????? ???????????? ??????????????????? ???????????? ?????? ????? ??????????? ?????????????? ????? ????? ????? ?????? ??????????????? ?????????? ?????????????? ???????????? ????*/