結果
問題 | No.1597 Matrix Sort |
ユーザー | ygd. |
提出日時 | 2021-07-31 20:45:14 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,316 bytes |
コンパイル時間 | 298 ms |
コンパイル使用メモリ | 86,972 KB |
実行使用メモリ | 670,284 KB |
最終ジャッジ日時 | 2023-10-14 15:10:22 |
合計ジャッジ時間 | 4,415 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
71,788 KB |
testcase_01 | AC | 98 ms
71,672 KB |
testcase_02 | AC | 100 ms
71,744 KB |
testcase_03 | MLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | MLE | - |
testcase_11 | MLE | - |
testcase_12 | AC | 178 ms
107,324 KB |
testcase_13 | AC | 496 ms
253,900 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 151 ms
103,688 KB |
testcase_16 | AC | 330 ms
259,608 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | MLE | - |
testcase_20 | MLE | - |
testcase_21 | MLE | - |
testcase_22 | MLE | - |
testcase_23 | MLE | - |
testcase_24 | AC | 140 ms
102,564 KB |
testcase_25 | AC | 142 ms
102,480 KB |
testcase_26 | AC | 96 ms
71,660 KB |
testcase_27 | AC | 98 ms
71,680 KB |
testcase_28 | AC | 96 ms
71,872 KB |
testcase_29 | MLE | - |
ソースコード
from collections import defaultdict import sys input = sys.stdin.buffer.readline def main(): N,K,P = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) dica = defaultdict(int) dicb = defaultdict(int) for a,b in zip(A,B): dica[a%P] += 1 dicb[b%P] += 1 #print(dica,dicb) #この累積和のメモリが重い sb = [0]*(P+1) for i in range(P): sb[i+1] = sb[i] + dicb[i] #累積和の時値のリストとその位置に対応する累積和をもって二分探索 #時間あるとき実装します。 #print(sb) #和がx以下となるのがk個以上あるか def solve(x): ret = 0 for i in dica: if i <= x: temp = sb[x-i+1] - sb[0] temp += sb[P] - sb[P-i] else: temp = sb[P+x-i+1] - sb[P-i] ret += temp*dica[i] #print(x,ret) return ret if solve(0) >= K: print(0);exit() ok = P ng = 0 #これは事前にチェック while abs(ok-ng) > 1: mid = (ok+ng)//2 #print(mid) if solve(mid) >= K: ok = mid else: ng = mid #print(solve(2)) print(ok) if __name__ == '__main__': main()