結果
問題 | No.390 最長の数列 |
ユーザー | amtgjw |
提出日時 | 2018-06-06 20:43:16 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 1,125 ms |
コンパイル使用メモリ | 70,388 KB |
実行使用メモリ | 7,556 KB |
最終ジャッジ日時 | 2023-09-12 22:51:00 |
合計ジャッジ時間 | 1,850 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
7,244 KB |
testcase_01 | AC | 5 ms
7,300 KB |
testcase_02 | AC | 5 ms
7,244 KB |
testcase_03 | AC | 5 ms
7,244 KB |
testcase_04 | AC | 5 ms
7,264 KB |
testcase_05 | AC | 41 ms
7,256 KB |
testcase_06 | AC | 55 ms
7,556 KB |
testcase_07 | AC | 5 ms
7,320 KB |
testcase_08 | AC | 5 ms
7,376 KB |
testcase_09 | AC | 6 ms
7,344 KB |
testcase_10 | AC | 45 ms
7,320 KB |
testcase_11 | AC | 44 ms
7,268 KB |
testcase_12 | AC | 45 ms
7,392 KB |
testcase_13 | AC | 35 ms
7,364 KB |
testcase_14 | AC | 39 ms
7,268 KB |
testcase_15 | AC | 5 ms
7,252 KB |
testcase_16 | AC | 5 ms
7,260 KB |
testcase_17 | AC | 6 ms
7,484 KB |
testcase_18 | AC | 8 ms
7,300 KB |
ソースコード
#include <iostream> #include <cstdio> #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 PER(i,n) for(int i=0;i>(n);--i) #define PERS(i,s,t) for(int i=(s);i>(t);--i) #define INF 2000000007 #define MINF -200000007 #define MOD 17 // 2^20 #define MAX 1000005 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> X(N); REP(i,N)cin>>X[i]; fill(dp,dp+MAX,MINF); sort(X.begin(),X.end()); REP(i,N){ int x = X[i]; if(dp[x]<0)dp[x]=1; REPS(j,1,X[N-1]){ if((j+1)*x > X[N-1])break; dp[(1+j)*x] = max(dp[(1+j)*x],dp[x]+1); } } int maxl=0; REP(i,N)maxl=max(maxl,dp[X[i]]); cout << maxl << endl; return 0; }