結果

問題 No.390 最長の数列
ユーザー mkawa2mkawa2
提出日時 2019-12-28 04:46:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,119 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 57,520 KB
最終ジャッジ日時 2024-04-19 04:37:59
合計ジャッジ時間 19,932 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 550 ms
44,388 KB
testcase_01 AC 557 ms
44,516 KB
testcase_02 AC 552 ms
44,388 KB
testcase_03 AC 539 ms
44,384 KB
testcase_04 AC 556 ms
44,156 KB
testcase_05 AC 670 ms
57,324 KB
testcase_06 AC 3,428 ms
57,520 KB
testcase_07 AC 542 ms
44,520 KB
testcase_08 AC 621 ms
51,936 KB
testcase_09 WA -
testcase_10 AC 914 ms
57,236 KB
testcase_11 AC 942 ms
57,412 KB
testcase_12 AC 916 ms
57,476 KB
testcase_13 AC 1,113 ms
56,432 KB
testcase_14 AC 1,098 ms
50,400 KB
testcase_15 AC 539 ms
44,128 KB
testcase_16 AC 619 ms
51,964 KB
testcase_17 AC 630 ms
52,208 KB
testcase_18 AC 630 ms
52,240 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):
            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