結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2018-05-31 17:13:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 867 bytes |
コンパイル時間 | 658 ms |
コンパイル使用メモリ | 71,028 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 08:32:29 |
合計ジャッジ時間 | 3,268 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 2 WA * 2 RE * 11 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <cmath> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0;i<(n);++i) #define REPS(i,s,t) for(int i=(s);i<(t);++i) #define INF 2000000007 #define MINF -200000007 #define MOD 1048576 // 2^20 #define MAX 100005 typedef unsigned int uint; typedef unsigned long long int ull; typedef long long int ll; int dp[MAX]; int main(){ int N;cin>>N; vector<int> A(N); REP(i,N)cin>>A[i]; int upper = A[N-1]; sort(A.begin(),A.end()); fill(dp,dp+upper,MINF); int maxl = 0; REP(i,N){ int X = A[i]; if(dp[X] < 0) dp[X]=1; REPS(j,2,upper+1){ if(ceil((1.0*X)/j) != floor((1.0*X)/j)) break; //cout << X << ":" << j << "[" << X/j << "]" << endl; dp[X] = max(dp[X],dp[X/j]+1); } } REP(i,N) maxl = max(maxl,dp[A[i]]); cout << maxl << endl; return 0; }