Submission #11102912


Source Code Expand

Copy
import collections

def solve(N, A):
    c = collections.Counter(A)
    originals = [0 for i in range(N + 1)]
    minus = [0 for i in range(N + 1)]
    for (k, v) in c.items():
        originals[k] = v * (v-1) // 2
        minus[k] = ((v * (v-1)) - (v-1) * (v-2)) // 2
    S = sum(originals)

    ans = []
    for a in A:
        ans.append(str(S - minus[a]))
    return "\n".join(ans)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split(" ")))
    print(solve(N, A))

Submission Info

Submission Time
Task D - Banned K
User mitsuo0114
Language Python (3.4.3)
Score 400
Code Size 521 Byte
Status AC
Exec Time 248 ms
Memory 34588 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 16
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All equal_01.txt, equal_02.txt, large_ans_01.txt, large_ans_02.txt, large_ans_03.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, rand_06.txt, rand_07.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
equal_01.txt AC 173 ms 32384 KB
equal_02.txt AC 173 ms 33196 KB
large_ans_01.txt AC 146 ms 24788 KB
large_ans_02.txt AC 145 ms 24784 KB
large_ans_03.txt AC 146 ms 24784 KB
rand_01.txt AC 234 ms 34428 KB
rand_02.txt AC 239 ms 34356 KB
rand_03.txt AC 248 ms 34356 KB
rand_04.txt AC 247 ms 34588 KB
rand_05.txt AC 237 ms 34360 KB
rand_06.txt AC 246 ms 34484 KB
rand_07.txt AC 239 ms 34460 KB
sample_01.txt AC 23 ms 3316 KB
sample_02.txt AC 23 ms 3316 KB
sample_03.txt AC 23 ms 3316 KB
sample_04.txt AC 23 ms 3316 KB