結果

問題 No.794 チーム戦 (2)
ユーザー やむなくやむなく
提出日時 2019-02-22 22:09:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,377 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 165,568 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-04 02:35:03
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 94 ms
6,940 KB
testcase_15 AC 93 ms
6,940 KB
testcase_16 AC 100 ms
6,940 KB
testcase_17 AC 93 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 58 ms
6,944 KB
testcase_23 AC 50 ms
6,940 KB
testcase_24 AC 39 ms
6,940 KB
testcase_25 AC 33 ms
6,944 KB
testcase_26 AC 37 ms
6,940 KB
testcase_27 AC 36 ms
6,940 KB
testcase_28 AC 35 ms
6,944 KB
testcase_29 AC 35 ms
6,940 KB
testcase_30 AC 35 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 40 ms
6,940 KB
testcase_34 AC 38 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main(){
  LL n,k;
  cin >> n >> k;
  vector<int> a(n);
  vector<LL> inv(n+1);
  inv[0]=1;
  for(int i=1;i<=n;i++){
    inv[i]=inv[i-1]*i%MOD;
  }

  for(int i=0;i<n;i++) cin >> a[i];
  sort(all(a));
  LL ans=1;
  for(int i=n-1;i>=0;i--){
    LL idx=distance(a.begin(),upper_bound(all(a),k-a[i]));
    if(idx-(n-1-i)<=0){
      cout << 0 << endl;
      return 0;
    }
    if(idx>i){
      LL nokori=n-2*(n-1-i);
      LL tmp=nokori/2;
      while(nokori){
        ans=(ans*(nokori*(nokori-1)/2))%MOD;
        nokori-=2;
      }
      ans=ans*modinv(inv[tmp],MOD)%MOD;
      break;
    }
    ans=(ans*(idx-(n-1-i)))%MOD;
  }
  cout << ans << endl;
  return 0;
}
0