結果

問題 No.794 チーム戦 (2)
ユーザー aa
提出日時 2019-02-23 05:40:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 171,176 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-08-18 11:44:07
合計ジャッジ時間 5,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 87 ms
4,644 KB
testcase_19 AC 85 ms
4,612 KB
testcase_20 AC 85 ms
4,668 KB
testcase_21 AC 87 ms
4,624 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 AC 32 ms
4,844 KB
testcase_31 AC 33 ms
4,524 KB
testcase_32 AC 33 ms
4,876 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9+7;

void solve()
{
	int N, K;
	cin >> N >> K;
	vector<long> as(N);
	for (int i = 0; i < N; i++) cin >> as[i];
	sort(as.begin(), as.end());
	if (as.front() + as.back() > K)
	{
		cout << 0 << endl;
		return;
	}
	long ans = 1, res = N;
	for (int i = N-1; i >= 0; i--)
	{
		long a = as[i];
		if (a*2 <= K) break;
		auto it = upper_bound(as.begin(), as.end(), K-a);
		ans *= (long)(it-as.begin());
		ans %= MOD;
		res-=2;
	}
	for (;res; res -= 2)
	{
		ans *= res-1;
		ans %= MOD;
	}
	ans %= MOD;
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
0