結果

問題 No.390 最長の数列
ユーザー ldsybldsyb
提出日時 2016-07-08 22:58:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 349 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 71,792 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 07:37:07
合計ジャッジ時間 29,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 3,362 ms
6,944 KB
testcase_14 TLE -
testcase_15 AC 2 ms
6,944 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:14:39: warning: '*(int*)dp' may be used uninitialized [-Wmaybe-uninitialized]
   14 |         cout << *max_element(dp,dp + n) << endl;
      |                                       ^
main.cpp:14:39: warning: '*(int*)dp' may be used uninitialized [-Wmaybe-uninitialized]

ソースコード

diff #

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

int main(){
	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(2 * x[i] == x[j]) dp[j] = max(dp[j],dp[i] + 1);
	cout << *max_element(dp,dp + n) << endl;
}
0