結果

問題 No.1515 Making Many Multiples
ユーザー だれだれ
提出日時 2021-04-26 15:14:01
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 747 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 129,284 KB
最終ジャッジ日時 2023-09-21 18:56:17
合計ジャッジ時間 14,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,236 KB
testcase_01 AC 85 ms
76,476 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 327 ms
109,044 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 71 ms
71,404 KB
testcase_25 AC 73 ms
75,556 KB
testcase_26 WA -
testcase_27 AC 594 ms
116,544 KB
testcase_28 AC 384 ms
115,604 KB
testcase_29 AC 125 ms
79,088 KB
testcase_30 AC 139 ms
78,824 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]

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

print(ans)
0