結果

問題 No.1597 Matrix Sort
ユーザー ophhdnophhdn
提出日時 2021-07-10 13:47:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,474 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 693,188 KB
最終ジャッジ日時 2023-09-14 19:10:02
合計ジャッジ時間 4,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
15,872 KB
testcase_01 AC 46 ms
11,608 KB
testcase_02 AC 48 ms
11,592 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor,atan2,sin,cos
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10**9+7


n,k,p=LI()
A=LI()
B=LI()
B=[b%p for b in B]
A=[a%p for a in A]
A.sort()
B.sort()
B+=[INF]
ok=p
ng=0
D={0:0}
j=0
for i in range(n+1):
    while j<p+2 and j<B[i]:
        j+=1
        D[j]=i


while ok-ng>1:
    mid=(ok+ng)//2
    r=n-1
    m = 0
    for i in range(n):
        if mid>A[i]:
            m+=n-(D[p-A[i]]-D[mid-A[i]+1])
        else:
            m+=(D[p-A[i]+mid+1]-D[p-A[i]])
    if m>=k:
        ok=mid
    else:
        ng=mid

print(ok)



0