結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | ayaoni |
提出日時 | 2021-07-24 13:41:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,171 ms / 2,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 1,407 ms |
コンパイル使用メモリ | 86,920 KB |
実行使用メモリ | 177,096 KB |
最終ジャッジ日時 | 2023-09-27 01:38:49 |
合計ジャッジ時間 | 8,971 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 90 ms
71,232 KB |
testcase_01 | AC | 90 ms
71,268 KB |
testcase_02 | AC | 90 ms
71,628 KB |
testcase_03 | AC | 89 ms
71,360 KB |
testcase_04 | AC | 90 ms
71,368 KB |
testcase_05 | AC | 90 ms
71,420 KB |
testcase_06 | AC | 90 ms
71,332 KB |
testcase_07 | AC | 90 ms
71,328 KB |
testcase_08 | AC | 91 ms
71,424 KB |
testcase_09 | AC | 90 ms
71,748 KB |
testcase_10 | AC | 957 ms
172,568 KB |
testcase_11 | AC | 967 ms
172,472 KB |
testcase_12 | AC | 977 ms
172,704 KB |
testcase_13 | AC | 143 ms
123,192 KB |
testcase_14 | AC | 1,171 ms
177,096 KB |
testcase_15 | AC | 1,023 ms
173,408 KB |
ソースコード
import sys from collections import defaultdict sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N = I() A = LI() M = max(A) div = [[] for _ in range(M+1)] for i in range(1,M+1): for j in range(2*i,M+1,i): div[j].append(i) dp = [0]*(M+1) for a in A: x = 1 for d in div[a]: x = max(x,dp[d]+1) dp[a] = x ans = max(dp) print(ans)