結果

問題 No.647 明太子
ユーザー GrayCoder
提出日時 2018-02-17 03:24:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 860 ms / 4,500 ms
コード長 774 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,068 KB
最終ジャッジ日時 2024-06-27 02:43:24
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

def main():
    N = int(input())
    A, B = [], []
    apndA, apndB = A.append, B.append
    for i in range(N):
        a, b = map(int, input().split())
        apndA((a, i))
        apndB((b, i))
    M = int(input())
    XY = tuple(tuple(map(int, input().split())) for _ in [0] * M)

    a, b = sorted(A), sorted(B)
    a = list(map(lambda *x: x, *a))
    b = list(map(lambda *x: x, *b))
    men = [0] * M
    for i, (x, y) in enumerate(XY):
        j = bisect.bisect_left(a[0], x)
        seta = set(a[1][j:])
        j = bisect.bisect(b[0], y)
        setb = set(b[1][:j])
        men[i] += len(seta & setb)

    max_ = max(men)
    if not max_:
        print(0)
    else:
        print(*[i + 1 for i, j in enumerate(men) if j == max_], sep='\n')


main()
0