結果

問題 No.979 Longest Divisor Sequence
ユーザー tamatotamato
提出日時 2020-01-31 22:15:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 751 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 127,552 KB
最終ジャッジ日時 2023-10-17 10:09:14
合計ジャッジ時間 5,751 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,532 KB
testcase_01 AC 38 ms
53,500 KB
testcase_02 AC 37 ms
53,500 KB
testcase_03 AC 38 ms
53,500 KB
testcase_04 AC 39 ms
53,500 KB
testcase_05 AC 38 ms
53,500 KB
testcase_06 AC 38 ms
53,500 KB
testcase_07 AC 38 ms
53,500 KB
testcase_08 AC 38 ms
53,500 KB
testcase_09 AC 38 ms
53,500 KB
testcase_10 AC 116 ms
62,008 KB
testcase_11 AC 114 ms
62,152 KB
testcase_12 AC 114 ms
62,008 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    dp = [[A[0]]]
    for a in A[1:]:
        ok = -1
        ng = len(dp)
        mid = (ok+ng)//2
        while ng - ok > 1:
            flg = 0
            for b in dp[mid]:
                if a%b == 0 and a > b:
                    #print(a, b, mid)
                    flg = 1
                    break
            if flg:
                #print(a, mid)
                ok = mid
            else:
                ng = mid
            mid = (ok+ng)//2
        if ok == len(dp)-1:
            dp.append([a])
        else:
            dp[ok+1].append(a)
    print(len(dp))
    #print(dp)


if __name__ == '__main__':
    main()
0