結果

問題 No.1515 Making Many Multiples
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-24 21:37:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,972 KB
最終ジャッジ日時 2024-04-21 07:09:12
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,840 KB
testcase_01 AC 58 ms
63,616 KB
testcase_02 AC 363 ms
107,520 KB
testcase_03 AC 387 ms
107,972 KB
testcase_04 AC 386 ms
107,392 KB
testcase_05 AC 379 ms
107,872 KB
testcase_06 AC 176 ms
107,868 KB
testcase_07 AC 201 ms
107,700 KB
testcase_08 AC 181 ms
83,072 KB
testcase_09 AC 233 ms
90,880 KB
testcase_10 AC 271 ms
91,008 KB
testcase_11 AC 332 ms
90,912 KB
testcase_12 AC 225 ms
89,168 KB
testcase_13 AC 70 ms
69,504 KB
testcase_14 AC 334 ms
90,880 KB
testcase_15 AC 70 ms
69,248 KB
testcase_16 AC 384 ms
105,344 KB
testcase_17 AC 127 ms
91,648 KB
testcase_18 AC 116 ms
91,940 KB
testcase_19 AC 71 ms
73,344 KB
testcase_20 AC 136 ms
84,864 KB
testcase_21 AC 255 ms
106,648 KB
testcase_22 AC 64 ms
67,328 KB
testcase_23 AC 277 ms
106,624 KB
testcase_24 AC 40 ms
51,840 KB
testcase_25 AC 43 ms
58,240 KB
testcase_26 AC 38 ms
51,968 KB
testcase_27 AC 280 ms
106,868 KB
testcase_28 AC 190 ms
107,104 KB
testcase_29 AC 62 ms
65,792 KB
testcase_30 AC 75 ms
68,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K, x, y = map(int, input().split())
A = list(map(lambda x: int(x) % K, input().split()))
x %= K
y %= K

# dp[i,j]: 手持ちがi,j -> 最大スコア
inf = 10**5
inf = 10
dp = [[-inf] * K for _ in range(K)]
memo = [-inf] * K
dp[x][y] = 0
dp[y][x] = 0
memo[x] = 0
memo[y] = 0

for a in A:
    for x in range(K):
        y = (K - x - a) % K
        if dp[x][y] >= 0:
            dp[x][y] += 1
            memo[x] = max(memo[x], dp[x][y])
    for x in range(K):
        if memo[x] < 0:
            continue
        dp[x][a] = max(dp[x][a], memo[x])
        dp[a][x] = max(dp[x][a], memo[x])
    memo[a] = max(dp[a])

ans = 0
for i in range(K):
    for j in range(K):
        ans = max(ans, dp[i][j])
print(ans)
0