結果

問題 No.794 チーム戦 (2)
ユーザー sinsincoscossinsincoscos
提出日時 2019-02-25 18:01:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 1,500 ms
コード長 934 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 69,628 KB
実行使用メモリ 8,136 KB
最終ジャッジ日時 2023-08-27 07:10:00
合計ジャッジ時間 6,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,388 KB
testcase_01 AC 2 ms
5,380 KB
testcase_02 AC 2 ms
5,568 KB
testcase_03 AC 2 ms
5,440 KB
testcase_04 AC 2 ms
5,484 KB
testcase_05 AC 2 ms
5,504 KB
testcase_06 AC 2 ms
5,488 KB
testcase_07 AC 2 ms
5,380 KB
testcase_08 AC 2 ms
5,384 KB
testcase_09 AC 2 ms
5,384 KB
testcase_10 AC 2 ms
5,688 KB
testcase_11 AC 2 ms
5,488 KB
testcase_12 AC 2 ms
5,504 KB
testcase_13 AC 2 ms
5,424 KB
testcase_14 AC 257 ms
8,080 KB
testcase_15 AC 255 ms
8,016 KB
testcase_16 AC 256 ms
8,012 KB
testcase_17 AC 252 ms
8,060 KB
testcase_18 AC 256 ms
8,136 KB
testcase_19 AC 256 ms
8,116 KB
testcase_20 AC 256 ms
8,136 KB
testcase_21 AC 256 ms
8,036 KB
testcase_22 AC 156 ms
6,804 KB
testcase_23 AC 142 ms
6,740 KB
testcase_24 AC 109 ms
6,836 KB
testcase_25 AC 93 ms
6,600 KB
testcase_26 AC 102 ms
6,536 KB
testcase_27 AC 199 ms
8,008 KB
testcase_28 AC 199 ms
8,020 KB
testcase_29 AC 198 ms
8,016 KB
testcase_30 AC 198 ms
8,116 KB
testcase_31 AC 199 ms
8,012 KB
testcase_32 AC 200 ms
8,012 KB
testcase_33 AC 200 ms
8,016 KB
testcase_34 AC 202 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

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-1]<=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+1-(i-1))%=inf;
		if(ans==0) break;
	}
	cout << ans << endl;
}
0