結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー 6soukiti296soukiti29
提出日時 2017-06-22 13:06:06
言語 Nim
(2.0.2)
結果
AC  
実行時間 85 ms / 3,000 ms
コード長 938 bytes
コンパイル時間 3,338 ms
コンパイル使用メモリ 70,600 KB
実行使用メモリ 16,936 KB
最終ジャッジ日時 2023-09-12 13:09:48
合計ジャッジ時間 5,203 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 80 ms
9,836 KB
testcase_08 AC 80 ms
9,512 KB
testcase_09 AC 54 ms
9,900 KB
testcase_10 AC 54 ms
9,584 KB
testcase_11 AC 63 ms
8,880 KB
testcase_12 AC 56 ms
10,692 KB
testcase_13 AC 85 ms
16,868 KB
testcase_14 AC 81 ms
16,220 KB
testcase_15 AC 83 ms
16,936 KB
testcase_16 AC 78 ms
10,500 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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 = reversed(A[0..n-1] & A[n + 1..high(A)])
    cnt = 0
    block hantei:
        var right = A2.high
        for i,a in A2:
            for j in countdown(right,i):
                if j == i:
                    break hantei
                if a + A2[j] > point:
                    right = j - 1
                    cnt += 1
                    break
    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