結果

問題 No.390 最長の数列
ユーザー ldsyb
提出日時 2016-07-08 23:15:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 392 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 70,296 KB
実行使用メモリ 10,660 KB
最終ジャッジ日時 2024-10-13 06:39:56
合計ジャッジ時間 7,046 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:39: warning: '*dp.5_37 + _10' may be used uninitialized [-Wmaybe-uninitialized]
   16 |         cout << *max_element(dp,dp + n) << endl;
      |                                       ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans = 0,n;
	cin >> n;
	int x[n];
	for(int i = 0;i < n;i++) cin >> x[i];
	sort(x,x + n);
	int dp[n];
	fill(dp,dp + n,1);
	for(int i = 0;i < n;i++) for(int j = i + 1;j < n;j++) if(x[j] % x[i] == 0) dp[j] = max(dp[j],dp[i] + 1);
	cout << *max_element(dp,dp + n) << endl;
}
0