結果

問題 No.794 チーム戦 (2)
ユーザー sinsincoscossinsincoscos
提出日時 2019-02-25 17:38:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 71,548 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-08-27 06:18:36
合計ジャッジ時間 8,058 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,464 KB
testcase_01 AC 2 ms
5,460 KB
testcase_02 AC 2 ms
5,396 KB
testcase_03 AC 2 ms
5,392 KB
testcase_04 AC 2 ms
5,588 KB
testcase_05 AC 2 ms
5,588 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,372 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 257 ms
8,012 KB
testcase_19 AC 258 ms
8,008 KB
testcase_20 AC 257 ms
8,004 KB
testcase_21 AC 258 ms
8,012 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
testcase_31 AC 203 ms
8,068 KB
testcase_32 AC 203 ms
8,064 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll N,K,A[200010] = {},inf = 1e9+7;

ll func[200010] = {0};
ll inv[200010] = {0};

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			func[i] = 1;
			inv[i] = 1;
		}
		else{
			func[i] = (i*func[i-1])%inf;
			inv[i] = mult(func[i],inf-2);
		}
	}
}


int main(){
	cin >> N >> K;
	factorial(N);
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	sort(A+1,A+N+1,greater<ll>());
	ll ans = 1;
	ll r = N+1;
	for(ll i=1;i<=N;i++){
		while(A[i]+A[r]<=K && i<r) r--;
		if(i==r){
			ll num = N-2*(i-1);
			(ans *= inv[num/2])%=inf;
			while(num>0){
				(ans *= (num*(num-1)/2)%inf)%=inf;
				num -= 2;
			}
			break;
		}
		(ans *= N-r)%=inf;
	}
	cout << ans << endl;
}
0