結果

問題 No.794 チーム戦 (2)
ユーザー azbrugbyazbrugby
提出日時 2019-02-23 15:24:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,705 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 11:53:23
合計ジャッジ時間 4,908 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define printf printf_s
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 20010, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838076673, MAX = 72340172838076673;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll n,k,a[N],mi,ans=1,ft[N],rv[N];

int main() {
	cin >> n >> k;
	ft[0] = 1; rv[0] = 1;
	for (int i = 1; i < N; i++) { 
		ft[i] = (ft[i - 1] * i) % MOD; 
		rv[i] = pw(ft[i], MOD - 2); 
	}
	for (int i = 1; i <= n; i++)cin >> a[i];
	sort(a, a + n);
	mi = upper_bound(a + 1, a + n + 1, k / 2) - a;
	if (n - mi + 1 > mi-1) {
		cout << 0 << endl;
	}
	else {
		for (int i = n,i2=0; i >=mi; i--,i2++) {
			ll v1 = upper_bound(a + 1, a + n + 1, k - a[i]) - a - 1;
			if (v1 <= i2)ans = 0;
			else ans *= (v1 - i2);
			ans %= MOD;
		}
		ll vv = 2 * mi - n - 2;
		ans *= rv[vv / 2]; ans %= MOD;
		for (int i = 2; i <= vv; i += 2) {
			ll v1 = (ft[i] * rv[2]) % MOD;
			v1 = (v1* rv[i - 2]) % MOD;
			ans = (ans*v1) % MOD;
		}
		cout << ans << endl;
	}
	return 0;
}
0