結果

問題 No.2218 Multiple LIS
ユーザー hiro71687khiro71687k
提出日時 2023-02-24 19:07:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,091 bytes
コンパイル時間 5,333 ms
コンパイル使用メモリ 268,128 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-11 04:03:27
合計ジャッジ時間 12,914 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,356 KB
testcase_13 AC 3 ms
4,352 KB
testcase_14 AC 3 ms
4,352 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 4 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 3 ms
4,352 KB
testcase_21 AC 370 ms
4,352 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
ll inf=10000000000000000;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    map<ll,ll>memo;
    for (ll i = 0; i < n; i++)
    {
        bool ok=false;
        ll now=1;
        vector<ll>kesu;
        for(auto v:memo){
            if (a[i]%v.first==0)
            {
                now=max(now,v.second+1);
            }
            if (v.first%a[i]==0)
            {
                if (now>=v.second)
                {
                    kesu.push_back(v.first);
                }
            }
        }
        if (!kesu.empty())
        {
            for (ll j = 0; j < kesu.size(); j++)
            {
                memo.erase(kesu[j]);
            }
            memo[a[i]]=now;
        }else{
            memo[a[i]]=now;
        }
    }
    ll ans=0;
    for(auto v:memo){
        ans=max(ans,v.second);
    }
    cout << ans << endl;
}
0