結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー yuruhiyayuruhiya
提出日時 2020-08-08 11:38:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 377 ms / 3,000 ms
コード長 389 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 31,956 KB
最終ジャッジ日時 2024-04-08 20:32:04
合計ジャッジ時間 5,663 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
16,256 KB
testcase_01 AC 81 ms
16,256 KB
testcase_02 AC 81 ms
16,256 KB
testcase_03 AC 80 ms
16,256 KB
testcase_04 AC 80 ms
16,256 KB
testcase_05 AC 81 ms
16,256 KB
testcase_06 AC 81 ms
16,256 KB
testcase_07 AC 377 ms
31,956 KB
testcase_08 AC 351 ms
31,188 KB
testcase_09 AC 377 ms
31,908 KB
testcase_10 AC 360 ms
31,908 KB
testcase_11 AC 352 ms
31,956 KB
testcase_12 AC 377 ms
31,908 KB
testcase_13 AC 349 ms
31,956 KB
testcase_14 AC 348 ms
31,956 KB
testcase_15 AC 348 ms
31,956 KB
testcase_16 AC 353 ms
31,956 KB
testcase_17 AC 81 ms
16,256 KB
testcase_18 AC 83 ms
16,256 KB
testcase_19 AC 83 ms
16,256 KB
testcase_20 AC 82 ms
16,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, m = gets.split.map &:to_i
x = gets.to_i
a = Array.new(n - 1) { gets.to_i }.sort.reverse
pos =
	a.bsearch_index do |ai|
		b = a.dup
		b.delete_at(a.index ai)
		j = b.size - 1
		cnt =
			(0...b.size).count do |i|
				j -= 1 while i < j && x + ai >= b[i] + b[j]
				if i >= j
					false
				else
					j -= 1
					true
				end
			end
		cnt >= m
	end || n - 1
puts pos > 0 ? a[pos - 1] : -1
0