結果
| 問題 |
No.794 チーム戦 (2)
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-02-22 21:44:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,524 bytes |
| コンパイル時間 | 837 ms |
| コンパイル使用メモリ | 98,176 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-11-25 06:47:41 |
| 合計ジャッジ時間 | 3,583 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 8 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
ll ap=a, ans=1;
while(k){
if(k&1){
ans*=ap;
ans%=MOD;
}
ap=ap*ap;
ap%=MOD;
k>>=1;
}
return ans;
}
ll inv(ll a){
return powmod(a, MOD-2);
}
ll f[200001], invf[200001];
void calc(int n){
f[0]=1;
for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
invf[n]=inv(f[n]);
for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
int n; ll k; cin>>n>>k;
calc(n);
ll a[200001];
for(int i=0; i<n; i++) cin>>a[i];
sort(a, a+n);
if(a[n-1]>=k){
cout<<0<<endl;
return 0;
}
int m=lower_bound(a, a+n, k/2)-a;
if(n-m>n/2){
cout<<0<<endl;
return 0;
}
int j=0;
ll ans=f[2*m-n]*invf[m-n/2]%MOD*powmod(5e8+4, m-n/2)%MOD;
for(int i=n-1; i>=m; i--){
while(j<m && a[j]+a[i]<=k) j++;
if(j-(n-1-i)<=0){
cout<<0<<endl;
return 0;
}
ans*=(ll)(j-(n-1-i));
ans%=MOD;
}
cout<<ans<<endl;
return 0;
}
chocorusk