結果

問題 No.794 チーム戦 (2)
ユーザー chocoruskchocorusk
提出日時 2019-02-22 21:47:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 97 ms / 1,500 ms
コード長 1,524 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 96,336 KB
実行使用メモリ 8,204 KB
最終ジャッジ日時 2023-08-16 17:33:36
合計ジャッジ時間 4,463 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 97 ms
8,068 KB
testcase_15 AC 96 ms
8,100 KB
testcase_16 AC 96 ms
8,056 KB
testcase_17 AC 96 ms
8,040 KB
testcase_18 AC 97 ms
8,040 KB
testcase_19 AC 97 ms
8,036 KB
testcase_20 AC 96 ms
8,048 KB
testcase_21 AC 96 ms
8,024 KB
testcase_22 AC 59 ms
6,220 KB
testcase_23 AC 53 ms
5,960 KB
testcase_24 AC 42 ms
5,388 KB
testcase_25 AC 36 ms
5,216 KB
testcase_26 AC 39 ms
5,216 KB
testcase_27 AC 39 ms
8,204 KB
testcase_28 AC 40 ms
8,092 KB
testcase_29 AC 37 ms
8,156 KB
testcase_30 AC 38 ms
8,024 KB
testcase_31 AC 39 ms
8,100 KB
testcase_32 AC 38 ms
8,024 KB
testcase_33 AC 38 ms
8,044 KB
testcase_34 AC 39 ms
8,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=upper_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;
}
0