Submission #4477633


Source Code Expand

Copy
N,M = map(int,input().split())
L = list(map(int,input().split()))
L.insert(0,0)
for i in range(1,N+1):
  L[i] = (L[i-1]+L[i])%M
L.sort()
p = L[0]
cnt = 1
ans = 0
L.append(10**18)
for i in range(N+1):
  if L[i+1] == p:
    cnt += 1
  else:
    if cnt == 1:
      cnt = 1
      p = L[i+1]
    else:
      ans += (cnt)*(cnt-1)//2
      cnt = 1
      p = L[i+1]
print(ans)

Submission Info

Submission Time
Task D - Candy Distribution
User Syuko4omi
Language Python3 (3.4.3)
Score 400
Code Size 389 Byte
Status
Exec Time 104 ms
Memory 14572 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 3064 KB
0_min1 18 ms 3064 KB
1_small0 18 ms 3064 KB
1_small1 18 ms 3064 KB
1_small2 17 ms 3064 KB
2_large0 19 ms 3188 KB
2_large1 90 ms 12940 KB
2_large2 79 ms 12180 KB
2_large3 59 ms 8988 KB
2_large4 87 ms 13628 KB
2_large5 27 ms 3316 KB
2_large6 70 ms 4556 KB
2_large7 67 ms 4348 KB
2_large8 18 ms 3064 KB
2_large9 46 ms 3884 KB
3_max0 104 ms 13928 KB
3_max1 100 ms 14572 KB
3_max2 97 ms 13644 KB
3_max3 85 ms 4660 KB
3_max4 83 ms 4660 KB
3_max5 81 ms 4660 KB
3_max6 100 ms 14480 KB
3_max7 100 ms 14480 KB
sample_01 18 ms 3064 KB
sample_02 18 ms 3064 KB
sample_03 18 ms 3064 KB