結果

問題 No.1515 Making Many Multiples
ユーザー だれだれ
提出日時 2021-04-28 18:01:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,009 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 129,256 KB
最終ジャッジ日時 2023-09-21 22:06:19
合計ジャッジ時間 17,193 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,184 KB
testcase_01 AC 87 ms
76,520 KB
testcase_02 AC 1,009 ms
128,688 KB
testcase_03 AC 969 ms
129,256 KB
testcase_04 AC 969 ms
129,072 KB
testcase_05 AC 989 ms
129,012 KB
testcase_06 AC 337 ms
109,168 KB
testcase_07 AC 561 ms
110,948 KB
testcase_08 AC 457 ms
89,948 KB
testcase_09 AC 699 ms
94,760 KB
testcase_10 AC 677 ms
105,804 KB
testcase_11 AC 806 ms
110,660 KB
testcase_12 AC 607 ms
93,368 KB
testcase_13 AC 128 ms
77,816 KB
testcase_14 AC 814 ms
112,180 KB
testcase_15 AC 133 ms
77,828 KB
testcase_16 AC 912 ms
113,532 KB
testcase_17 AC 281 ms
95,420 KB
testcase_18 AC 234 ms
99,012 KB
testcase_19 AC 141 ms
86,988 KB
testcase_20 AC 316 ms
90,700 KB
testcase_21 AC 598 ms
113,784 KB
testcase_22 AC 117 ms
77,180 KB
testcase_23 AC 679 ms
112,712 KB
testcase_24 AC 76 ms
71,412 KB
testcase_25 AC 79 ms
75,580 KB
testcase_26 AC 76 ms
71,160 KB
testcase_27 AC 783 ms
117,752 KB
testcase_28 AC 479 ms
116,640 KB
testcase_29 AC 125 ms
79,112 KB
testcase_30 AC 142 ms
78,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

n, k, X, Y = map(int, input().split())
dp = [[-1e9] * k for _ in range(k)]
a = list(map(int, input().split()))

for i in range(n):
    a[i] %= k

X %= k
Y %= k

mx = [-1e9] * k
mx[X] = mx[Y] = 0

dp[X][Y] = 0
dp[Y][X] = 0

for i in range(n):
    x = a[i]
    for j in range(k):
        l = (k - (j + x) % k) % k
        dp[j][l] += 1
        if dp[j][l] > mx[j]:
            mx[j] = dp[j][l]
        if dp[j][l] > mx[l]:
            mx[l] = dp[j][l]
    
    for j in range(k):
        if dp[j][x] < mx[j]:
            dp[j][x] = mx[j]
        if dp[x][j] < mx[j]:
            dp[x][j] = mx[j]
    
    for j in range(k):
        if mx[x] < mx[j]:
            mx[x] = mx[j]

ans = 0
for i in range(k):
    for j in range(k):
        if ans < dp[i][j]:
            ans = dp[i][j]

print(ans)
0