結果
問題 |
No.1515 Making Many Multiples
|
ユーザー |
![]() |
提出日時 | 2021-04-28 18:01:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 942 ms / 2,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 116,928 KB |
最終ジャッジ日時 | 2024-07-07 15:16:04 |
合計ジャッジ時間 | 13,611 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
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)