結果

問題 No.794 チーム戦 (2)
ユーザー ttttanttttan
提出日時 2019-03-03 22:59:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,035 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 150,464 KB
実行使用メモリ 8,068 KB
最終ジャッジ日時 2023-09-05 17:50:40
合計ジャッジ時間 4,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 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 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 106 ms
7,792 KB
testcase_17 AC 106 ms
7,796 KB
testcase_18 AC 102 ms
7,916 KB
testcase_19 AC 102 ms
8,052 KB
testcase_20 AC 101 ms
7,748 KB
testcase_21 AC 101 ms
7,768 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 44 ms
7,896 KB
testcase_30 AC 44 ms
7,748 KB
testcase_31 AC 45 ms
7,896 KB
testcase_32 AC 44 ms
8,056 KB
testcase_33 AC 47 ms
7,896 KB
testcase_34 AC 47 ms
7,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll> a(n);for(ll i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    ll are[n+2];
    are[0]=0;
    are[1]=1;
    for(ll i=2;i<=n+1;i++){
        ll u=are[i-1]*(2*i-1);
        u%=mod;
        are[i]=u;
    }
    ll tai[n];
    for(ll i=n-1;i>=0;i--){
        ll y=k-a[i];
        ll u=upper_bound(a.begin(),a.end(),y)-a.begin();
        tai[i]=u;
    }
    for(ll i=0;i<n/2;i++){
        if(a[i]+a[n-1-i]>k){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=0;
    ll now=1;
    for(ll i=n-1;i>=0;i--){
        ll sum=1;
        ll t=tai[i];
        if(t>=i)break;
        if(i<n-1){
            now*=(t-n+2+i);
            now%=mod;
        }
        sum*=now*(i-t);
        sum%=mod;
        sum*=are[n/2-n+i];
        sum%=mod;
        ans+=sum;
        ans%=mod;
            
    }
    ll rr=are[n/2];
    ll anss=rr-ans;
    anss+=mod;
    cout<<anss%mod<<endl;
    
}
0