結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー 6soukiti296soukiti29
提出日時 2017-06-22 12:35:22
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 3,448 ms
コンパイル使用メモリ 70,788 KB
実行使用メモリ 12,452 KB
最終ジャッジ日時 2023-09-12 13:09:13
合計ジャッジ時間 8,912 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils,sequtils,algorithm
var
    L : seq[int]
    N,M,Ma,mi,n : int
    A,A2 : seq[int]
    k : int
    I,p,cnt,point,j,index : int
A = @[]
L = stdin.readline.split.map(parseInt)
(N,M) = (L[0],L[1])
I = stdin.readline.parseInt
for n in 0..<N - 1:
    k = stdin.readline.parseInt
    A.add(k)
A.sort(system.cmp)
Ma = N - 1
mi = 0
while Ma - mi > 0:
    n = (Ma + mi) div 2
    p = A[n]
    point = I + p
    A2 = A[0..n-1] & A[n + 1..high(A)]
    cnt = 0
    for i,a in reversed(A2):
        j = point - a
        if j <= 0:
            cnt += A2.len - i - 1
            continue
        index = lowerBound(A2[0..high(A2)-i-1],j + 1)
        index = A2.len - i - 1 - index
        if index == 0:
            break
        cnt += index
    if cnt >= M:
        mi = n + 1
    if cnt < M:
        Ma = n
    if Ma <= N - 2 and A[mi] == A[Ma]:
        break
if mi > N - 2:
    echo -1
else:
    echo A[mi]
0