結果

問題 No.390 最長の数列
ユーザー fmhrfmhr
提出日時 2016-07-08 23:19:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 165,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 08:05:19
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 28 ms
6,940 KB
testcase_14 AC 38 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define MAX 100000

using namespace std;

int n;
int A[MAX + 1];
int L[MAX];

int lis() {
    L[0] = A[0];
    int length = 1;
    for (int i = 1; i < n; ++i) {
        if (L[length - 1] < A[i] && A[i] % L[length - 1] == 0) {
            L[length++] = A[i];
        } else {
            *lower_bound(L, L + length, A[i]) = A[i];
        }
    }
    return lower_bound(L, L + length, MAX) - L;
}


int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(begin(A), begin(A) + n - 1);
    cout << lis() << endl;
    return 0;
};
0