Submission #31069454


Source Code Expand

import bisect
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
answer = 0
for i in range(n):
    for j in range(i + 1, n):
        max_k = bisect.bisect_left(l, l[i] + l[j])
        # j + 1 以上 max_k 未満の k が条件を満たす
        answer += max_k - (j + 1)
print(answer)

Submission Info

Submission Time
Task D - Triangles
User Pro_ktmr
Language PyPy3 (7.3.0)
Score 400
Code Size 312 Byte
Status AC
Exec Time 375 ms
Memory 74508 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample00, sample01, sample02
All handmade03, handmade04, handmade05, random06, random07, random08, random09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 AC 67 ms 61772 KiB
handmade04 AC 212 ms 73892 KiB
handmade05 AC 53 ms 61756 KiB
random06 AC 367 ms 74380 KiB
random07 AC 362 ms 74088 KiB
random08 AC 365 ms 74040 KiB
random09 AC 366 ms 74088 KiB
random10 AC 371 ms 74468 KiB
random11 AC 356 ms 74508 KiB
random12 AC 366 ms 74040 KiB
random13 AC 282 ms 74476 KiB
random14 AC 375 ms 74356 KiB
sample00 AC 52 ms 61796 KiB
sample01 AC 49 ms 61936 KiB
sample02 AC 51 ms 61956 KiB