結果
| 問題 |
No.3166 [Cherry 7th Tune *] 桜の守人
|
| コンテスト | |
| ユーザー |
timi
|
| 提出日時 | 2025-06-12 16:59:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 471 ms / 2,000 ms |
| コード長 | 916 bytes |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 82,056 KB |
| 実行使用メモリ | 157,516 KB |
| 最終ジャッジ日時 | 2025-06-12 17:00:08 |
| 合計ジャッジ時間 | 11,908 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
import heapq
from heapq import heappop,heappush,heapify
from sys import stdin, setrecursionlimit
input = stdin.readline
readline = stdin.readline
from collections import deque,defaultdict
from collections import deque
d=deque()
T=int(input())
for i in range(T):
N,L,K=map(int, input().split())
A=list(map(int, input().split()))
A=sorted(A)
ng,ok=0,L+1
while ok-ng>1:
mid=(ok+ng)//2
C=[0,L]
D=defaultdict(int)
for a in A:
if a-mid>=0:
D[a-mid]+=1
C.append(a-mid)
else:
D[0]+=1
D[a-mid+L]+=1
C.append(a-mid+L)
if a+mid<L:
r=a+mid
D[r]-=1
C.append(r)
else:
D[0]+=1
D[a+mid-L]-=1
C.append(a+mid-L)
C=sorted(list(set(C)))
c=0
he=10**10
for i in range(len(C)-1):
c+=D[C[i]]
he=min(he,c)
if he>=K:
ok=mid
else:
ng=mid
print(ok)
timi