Submission #56088391


Source Code Expand

(N,Q),A,*BK = $<.map{|ln| ln.split.map(&:to_i) }
A.sort!
puts BK.map{|b,k|
	# k 幅の左インデックスは 0..N-k
	i1 = (0...N-k).bsearch{|i| # 右端が左端より遠くなるのは
		b-A[i]<A[i+k-1]-b
	}||N-k
	i0 = [i1-1,0].max
	next [i1,i0].map{|i|
		A.values_at(i,i+k-1).map{|a| (a-b).abs }.max
	}.min
}

Submission Info

Submission Time
Task D - K-th Nearest
User ds14050
Language Ruby (ruby 3.2.2)
Score 425
Code Size 325 Byte
Status AC
Exec Time 340 ms
Memory 28348 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 21
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_minmax_00.txt, 02_minmax_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 92 ms 17068 KiB
00_sample_01.txt AC 42 ms 17276 KiB
00_sample_02.txt AC 43 ms 17192 KiB
01_random_00.txt AC 125 ms 20804 KiB
01_random_01.txt AC 331 ms 26880 KiB
01_random_02.txt AC 237 ms 25100 KiB
01_random_03.txt AC 331 ms 26392 KiB
01_random_04.txt AC 256 ms 23876 KiB
01_random_05.txt AC 332 ms 26764 KiB
01_random_06.txt AC 85 ms 22636 KiB
01_random_07.txt AC 327 ms 26800 KiB
01_random_08.txt AC 251 ms 26328 KiB
01_random_09.txt AC 330 ms 26752 KiB
01_random_10.txt AC 99 ms 24344 KiB
01_random_11.txt AC 332 ms 26564 KiB
01_random_12.txt AC 293 ms 25672 KiB
01_random_13.txt AC 340 ms 26320 KiB
01_random_14.txt AC 195 ms 24988 KiB
01_random_15.txt AC 263 ms 27368 KiB
02_minmax_00.txt AC 42 ms 16992 KiB
02_minmax_01.txt AC 309 ms 28348 KiB