結果

問題 No.647 明太子
ユーザー GrayCoder
提出日時 2018-02-12 07:59:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 563 ms / 4,500 ms
コード長 780 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-06-27 02:41:00
合計ジャッジ時間 3,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import heapq

def main():
    N = int(input())
    AB = []
    for i in (tuple(map(int, input().split())) for _ in [0] * N):
        heapq.heappush(AB, i)
    M = int(input())
    XY = tuple(tuple(map(int, input().split())) for _ in [0] * M)

    a = [0] * N
    b = a[:]
    for i in range(N):
        a[i], b[i] = heapq.heappop(AB)

    men = [0] * M
    for i, (x, y) in enumerate(XY):
        j = bisect.bisect_left(a, x)
        b_ = b[j:]
        b_.sort()
        k = bisect.bisect(b_, y)
        men[i] += k

    max_ = max(men)
    if not max_:
        print(0)
    else:
        i = 0
        try:
            while 1:
                j = men.index(max_, i)
                print(j + 1)
                i = j + 1
        except:
            return

main()
0