提出 #8610433


ソースコード 拡げる

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
from collections import defaultdict

N,K,*A = map(int,read().split())

A = [0] + [x-1 for x in A]

# 和が0となる場所を答えればよい

Acum = list(itertools.accumulate(A))
Acum = [x % K for x in Acum]

counter = defaultdict(int)
answer = 0
for i,x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-K+1]] -= 1

print(answer)

提出情報

提出日時
問題 E - Rem of Sum is Num
ユーザ maspy
言語 Python (3.4.3)
得点 500
コード長 548 Byte
結果 AC
実行時間 240 ms
メモリ 41416 KiB

ジャッジ結果

セット名 sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 29
セット名 テストケース
sample sample01, sample02, sample03
All few01, few02, few03, hand01, hand02, hand03, hand04, large01, large02, large03, max01, max02, max03, mid01, mid02, mid03, mid04, mid05, min01, min02, min03, sample01, sample02, sample03, small01, small02, small03, small04, small05
ケース名 結果 実行時間 メモリ
few01 AC 199 ms 20684 KiB
few02 AC 197 ms 25380 KiB
few03 AC 199 ms 25760 KiB
hand01 AC 20 ms 3316 KiB
hand02 AC 218 ms 22240 KiB
hand03 AC 225 ms 22220 KiB
hand04 AC 183 ms 22244 KiB
large01 AC 219 ms 39800 KiB
large02 AC 235 ms 41416 KiB
large03 AC 230 ms 40508 KiB
max01 AC 240 ms 41188 KiB
max02 AC 225 ms 41188 KiB
max03 AC 217 ms 41188 KiB
mid01 AC 22 ms 3564 KiB
mid02 AC 22 ms 3692 KiB
mid03 AC 23 ms 3564 KiB
mid04 AC 22 ms 3564 KiB
mid05 AC 23 ms 3564 KiB
min01 AC 164 ms 17020 KiB
min02 AC 163 ms 16432 KiB
min03 AC 169 ms 17480 KiB
sample01 AC 20 ms 3316 KiB
sample02 AC 20 ms 3316 KiB
sample03 AC 20 ms 3316 KiB
small01 AC 20 ms 3316 KiB
small02 AC 20 ms 3316 KiB
small03 AC 20 ms 3316 KiB
small04 AC 20 ms 3316 KiB
small05 AC 20 ms 3316 KiB