結果

問題 No.989 N×Mマス計算(K以上)
ユーザー ThetaTheta
提出日時 2022-10-21 13:52:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 16,708 KB
最終ジャッジ日時 2023-09-13 15:18:47
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,956 KB
testcase_01 AC 18 ms
8,064 KB
testcase_02 AC 17 ms
8,008 KB
testcase_03 AC 18 ms
7,940 KB
testcase_04 AC 17 ms
7,944 KB
testcase_05 AC 17 ms
8,032 KB
testcase_06 AC 18 ms
7,932 KB
testcase_07 AC 17 ms
7,952 KB
testcase_08 AC 17 ms
7,992 KB
testcase_09 AC 17 ms
7,952 KB
testcase_10 AC 176 ms
13,508 KB
testcase_11 AC 113 ms
15,576 KB
testcase_12 AC 173 ms
14,704 KB
testcase_13 AC 58 ms
13,596 KB
testcase_14 AC 248 ms
16,708 KB
testcase_15 AC 84 ms
10,400 KB
testcase_16 AC 140 ms
12,168 KB
testcase_17 AC 55 ms
13,716 KB
testcase_18 AC 147 ms
10,320 KB
testcase_19 AC 106 ms
15,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
from operator import add, mul, sub, truediv


def main():
    N, M, K = map(int, input().split())

    op, *B = input().split()
    B = list(map(int, B))
    B.sort()
    A = [int(input()) for _ in range(N)]
    A.sort()

    match op:
        case "+":
            op_func = sub
        case "*":
            op_func = truediv
        case _:
            raise ValueError

    ctr = 0
    b_idx = None
    for row, a_elm in enumerate(A):
        b_idx = bisect_left(B, op_func(K, a_elm), hi=b_idx)
        ctr += len(B) - b_idx
    print(ctr)


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