1 solutions

  • 0
    @ 2022-9-12 0:29:56

    把区间差分一下,然后遍历1110510^5统计一下答案即可。

    n=int(input())
    a=[0 for i in range(100005)]
    for i in range(n):
        l,r=map(int,input().split())
        a[l]+=1
        a[r+1]-=1
    for i in range(1,100001):
        a[i]+=a[i-1]
    k=max(a)
    cnt=0
    for i in range(len(a)):
        if a[i]==k:
            cnt+=1
    print(cnt,k)
    

    Information

    ID
    5
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    246
    Accepted
    52
    Uploaded By