結果

問題 No.794 チーム戦 (2)
ユーザー titia
提出日時 2019-02-22 22:35:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 366 ms / 1,500 ms
コード長 600 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 32,660 KB
最終ジャッジ日時 2024-11-25 09:58:16
合計ジャッジ時間 5,584 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

A.sort(reverse=True)

LIST=[-1]*N

for j in range(N):
    if A[0]+A[j]<=K:
        break
else:
    print(0)
    sys.exit()

if j>1:
    LIST[0]=j

    i=1
    while j>i+1:
        if A[i]+A[j-1]<=K:
            j-=1
        else:
            LIST[i]=j
            i+=1

ANS=1
for i in range(N//2):
    if LIST[i]!=-1:
        ANS=ANS*max(0,(N-LIST[i]-i))%mod
    else:
        rest=N-2*i
        for j in range(1,rest,2):
            ANS=ANS*j%mod

        print(ANS)
        sys.exit()
0