結果

問題 No.794 チーム戦 (2)
ユーザー pockyny
提出日時 2019-03-16 06:45:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 1,500 ms
コード長 424 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 70,612 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-07-01 22:21:30
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[200010],b[200010],ans = 1,mod = 1000000007;
int main(){
	int i,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a + n);
	int j = -1;
	for(i=n-1;i>=0;i--){
		while(a[j+1]+a[i]<=k && j+1<n) j++;
		b[i] = min(i - 1,j) + 1;
	}
	j = 0;
	for(i=n-1;i>=n/2;i--){
		(ans *= (b[i] - j)) %= mod;
		j++;
	}
	cout << ans << endl;
}
0