結果

問題 No.794 チーム戦 (2)
ユーザー leaf_1415leaf_1415
提出日時 2019-02-22 21:47:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 1,500 ms
コード長 589 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 63,284 KB
実行使用メモリ 5,240 KB
最終ジャッジ日時 2023-08-16 17:31:11
合計ジャッジ時間 3,491 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 83 ms
4,900 KB
testcase_15 AC 84 ms
4,964 KB
testcase_16 AC 84 ms
4,980 KB
testcase_17 AC 80 ms
4,960 KB
testcase_18 AC 80 ms
4,964 KB
testcase_19 AC 81 ms
5,032 KB
testcase_20 AC 81 ms
5,036 KB
testcase_21 AC 80 ms
4,928 KB
testcase_22 AC 52 ms
4,624 KB
testcase_23 AC 47 ms
4,376 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 30 ms
4,376 KB
testcase_26 AC 33 ms
4,380 KB
testcase_27 AC 31 ms
4,888 KB
testcase_28 AC 33 ms
5,240 KB
testcase_29 AC 30 ms
5,140 KB
testcase_30 AC 30 ms
4,888 KB
testcase_31 AC 30 ms
4,928 KB
testcase_32 AC 30 ms
4,968 KB
testcase_33 AC 30 ms
4,912 KB
testcase_34 AC 30 ms
5,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:17: warning: ‘rem’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  for(int i = rem-1; i > 0; i-=2) ans *= i, ans %= mod;
              ~~~^~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, k;
llint a[200005];

int main(void)
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	llint ans = 1, rem;
	for(int i = n; i >= 1; i--){
		if(a[i] <= k/2){
			rem = n - 2*(n-i);
			break;
		}
		int cnt = upper_bound(a+1, a+n+1, k-a[i]) - (a+1);
		cnt -= (n-i);
		if(cnt <= 0){
			cout << 0 << endl;
			return 0;
		}
		ans *= cnt, ans %= mod;
	}
	
	for(int i = rem-1; i > 0; i-=2) ans *= i, ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0