結果

問題 No.989 N×Mマス計算(K以上)
ユーザー Tsubo
提出日時 2020-03-10 20:59:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,528 KB
最終ジャッジ日時 2024-11-15 23:37:02
合計ジャッジ時間 2,326 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M,K=map(int,readline().split())
    opB=readline().split()
    op=opB[0]
    B=list(map(int,opB[1:]))
    A=[0]*N
    for i in range(N):
        A[i]=int(readline())
    A.sort()
    B.sort(reverse=True)

    now=0
    count=0
    for i in range(N):
        if op=="+":
            while now<M and A[i]+B[now]>=K:
                now+=1
        elif op=="*":
            while now<M and A[i]*B[now]>=K:
                now+=1
        count+=now
        
    print(count)

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