結果

問題 No.2517 Right Triangles on Circle
ユーザー ThetaTheta
提出日時 2023-11-21 19:12:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 556 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 46,740 KB
最終ジャッジ日時 2023-11-21 19:12:13
合計ジャッジ時間 8,539 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 31 ms
10,112 KB
testcase_03 AC 32 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 28 ms
10,112 KB
testcase_06 AC 28 ms
10,112 KB
testcase_07 AC 28 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 28 ms
10,112 KB
testcase_11 AC 28 ms
10,112 KB
testcase_12 AC 29 ms
10,112 KB
testcase_13 AC 403 ms
46,740 KB
testcase_14 AC 201 ms
46,740 KB
testcase_15 AC 426 ms
42,932 KB
testcase_16 AC 556 ms
42,932 KB
testcase_17 AC 328 ms
38,744 KB
testcase_18 AC 311 ms
37,020 KB
testcase_19 AC 269 ms
32,384 KB
testcase_20 AC 275 ms
34,128 KB
testcase_21 AC 423 ms
44,964 KB
testcase_22 AC 73 ms
19,080 KB
testcase_23 AC 289 ms
33,808 KB
testcase_24 AC 141 ms
21,316 KB
testcase_25 AC 65 ms
17,676 KB
testcase_26 AC 337 ms
38,268 KB
testcase_27 AC 70 ms
18,464 KB
testcase_28 AC 73 ms
14,784 KB
testcase_29 AC 136 ms
20,880 KB
testcase_30 AC 89 ms
16,400 KB
testcase_31 AC 289 ms
33,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right


def main():
    N, M = map(int, input().split())
    A = sorted(map(int, input().split()))
    if M % 2 == 1:
        print(0)
        return

    triangles = 0
    for a_elm in A:
        if a_elm * 2 > M:
            break
        opposite = a_elm + M // 2
        idx_1 = bisect_left(A, opposite)
        idx_2 = bisect_right(A, opposite)
        if idx_1 < idx_2:
            triangles += N - 2

    print(triangles)


if __name__ == "__main__":
    main()
0