結果
| 問題 |
No.1977 Extracting at Constant Intervals
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:53:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,418 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,540 KB |
| 実行使用メモリ | 726,776 KB |
| 最終ジャッジ日時 | 2025-06-12 20:57:48 |
| 合計ジャッジ時間 | 3,929 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | MLE * 1 -- * 30 |
ソースコード
import sys
import math
def main():
N, M, L = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
R = L % N
max_C = -float('inf')
if R == 0:
for i in range(1, L+1):
p = (i - 1) % N
a = A[p]
max_j = N * M
count = 0
if i <= max_j:
count = (max_j - i) // L + 1
total = a * count
if total > max_C:
max_C = total
else:
g = math.gcd(R, N)
D = N // g
cycles = []
for p0 in range(N):
current = p0
cycle = []
for _ in range(D):
cycle.append(A[current])
current = (current + R) % N
cycles.append(cycle)
sum_cycle = [sum(c) for c in cycles]
prefix = []
for c in cycles:
pre = [0]
for num in c:
pre.append(pre[-1] + num)
prefix.append(pre)
for i in range(1, L+1):
p0 = (i - 1) % N
max_j = N * M
if i > max_j:
continue
T = (max_j - i) // L
count = T + 1
full = count // D
rem = count % D
s = full * sum_cycle[p0] + prefix[p0][rem]
if s > max_C:
max_C = s
print(max_C)
if __name__ == "__main__":
main()
gew1fw