結果

問題 No.390 最長の数列
ユーザー mkawa2mkawa2
提出日時 2019-12-28 04:47:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,990 ms / 5,000 ms
コード長 1,121 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 57,240 KB
最終ジャッジ日時 2024-04-19 04:41:24
合計ジャッジ時間 16,784 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 526 ms
44,256 KB
testcase_01 AC 508 ms
43,872 KB
testcase_02 AC 556 ms
43,868 KB
testcase_03 AC 470 ms
44,124 KB
testcase_04 AC 458 ms
44,128 KB
testcase_05 AC 574 ms
56,984 KB
testcase_06 AC 2,990 ms
56,984 KB
testcase_07 AC 483 ms
43,876 KB
testcase_08 AC 573 ms
51,692 KB
testcase_09 AC 692 ms
52,068 KB
testcase_10 AC 843 ms
57,240 KB
testcase_11 AC 813 ms
56,984 KB
testcase_12 AC 793 ms
57,240 KB
testcase_13 AC 948 ms
56,420 KB
testcase_14 AC 983 ms
50,144 KB
testcase_15 AC 468 ms
44,004 KB
testcase_16 AC 538 ms
51,816 KB
testcase_17 AC 551 ms
52,068 KB
testcase_18 AC 581 ms
51,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    aa=LI()
    m=max(aa)
    dp=[-1]*(m+1)
    for a in aa:
        dp[a]=1
    for i in range(1,m):
        pre=dp[i]
        if pre==-1:continue
        for j in range(2,m+5):
            if i*j>m:break
            if dp[i*j]==-1:continue
            dp[i*j]=max(dp[i*j],pre+1)
    print(max(dp))

main()
0