結果

問題 No.794 チーム戦 (2)
ユーザー 沙耶花
提出日時 2022-07-30 14:11:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 171 ms / 1,500 ms
コード長 692 bytes
コンパイル時間 4,334 ms
コンパイル使用メモリ 254,792 KB
最終ジャッジ日時 2025-01-30 16:38:42
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000

int main() {
    
	int N,K;
	cin>>N>>K;
	vector<int> a(N);
	rep(i,N)cin>>a[i];
	
	sort(a.rbegin(),a.rend());
	mint ans = 1;
	int cur = N-1;
	rep(i,N-1){
		if(a[i+1]+a[i]<=K){
			int remain = N;
			remain -= i*2;
			remain --;
			while(remain>0){
				ans *= remain;
				remain-=2;
			}
			break;
		}
		else{
			while(a[cur]+a[i]<=K)cur--;
			int sum = N-1 - cur;
			sum -= i;
			if(sum<0){
				ans = 0;
				break;
			}
			ans *= sum;
		}
		
		
	}
	
	cout<<ans.val()<<endl;
	
    return 0;
}
0