結果

問題 No.390 最長の数列
ユーザー HachimoriHachimori
提出日時 2016-07-08 22:58:05
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 801 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 68,956 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-21 07:35:41
合計ジャッジ時間 7,175 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
const int BUF = 100005;


int nVal;
int val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


void work() {
    sort(val, val + nVal);
    
    multimap<int, int> leng2val;

    for (int i = 0; i < nVal; ++i) {
        int toAdd = 1;
        for (multimap<int, int>::reverse_iterator it = leng2val.rbegin();
             it != leng2val.rend();
             ++it) {
            
            if (val[i] % it->second == 0) {
                toAdd = it->first + 1;
                break;
            }
        }
        leng2val.insert(make_pair(toAdd, val[i]));
    }

    cout << leng2val.rbegin()->first << endl;
}


int main() {
    read();
    work();
    return 0;
}
0