Submission #7339147


Source Code Expand

Copy
n, m = map(int, input().split())
a = [ int(x) for x in input().split() ]

# mod をとった累積和をとる
for k, v in enumerate(a):
    if k != 0:
        a[k] += a[k-1]
    a[k] %= m

ans = 0
dic = {}

for aa in a:
    dic[aa] = (dic.get(aa, 0) + 1)

    if aa == 0:
        ans += dic[aa]
    else:
        ans += dic[aa] - 1

print(ans)

Submission Info

Submission Time
Task D - Candy Distribution
User kira924age
Language Python3 (3.4.3)
Score 400
Code Size 366 Byte
Status
Exec Time 134 ms
Memory 14252 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 400 / 400 0_min0, 0_min1, 1_small0, 1_small1, 1_small2, 2_large0, 2_large1, 2_large2, 2_large3, 2_large4, 2_large5, 2_large6, 2_large7, 2_large8, 2_large9, 3_max0, 3_max1, 3_max2, 3_max3, 3_max4, 3_max5, 3_max6, 3_max7, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_min0 17 ms 3060 KB
0_min1 17 ms 3060 KB
1_small0 17 ms 3060 KB
1_small1 17 ms 3060 KB
1_small2 17 ms 3060 KB
2_large0 19 ms 3188 KB
2_large1 126 ms 12940 KB
2_large2 109 ms 11620 KB
2_large3 80 ms 8992 KB
2_large4 125 ms 12600 KB
2_large5 34 ms 3316 KB
2_large6 104 ms 4500 KB
2_large7 91 ms 4292 KB
2_large8 18 ms 3060 KB
2_large9 59 ms 3756 KB
3_max0 126 ms 13800 KB
3_max1 124 ms 13652 KB
3_max2 134 ms 13644 KB
3_max3 110 ms 4908 KB
3_max4 109 ms 4908 KB
3_max5 109 ms 4896 KB
3_max6 123 ms 14252 KB
3_max7 127 ms 14252 KB
sample_01 17 ms 3060 KB
sample_02 17 ms 3060 KB
sample_03 17 ms 3060 KB