結果

問題 No.794 チーム戦 (2)
ユーザー TomoyaTomoya
提出日時 2019-02-22 23:50:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,294 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 92,164 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-17 08:05:42
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 41 ms
4,376 KB
testcase_17 AC 41 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 21 ms
4,380 KB
testcase_30 AC 17 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

//解説AC
//https://yukicoder.me/submissions/318714


int mod_pow(int n, int k) {
  int res = 1;
  for(; k>0; k>>=1) {
    if(k & 1) (res *= n) %= MOD;
    (n *= n) %= MOD;
  }
  return res;
}
int calc(int teams){
  int res = 1;
  for(int i=1; i<=2*teams; i++) {
    (res *= i) %= MOD;
  }
  for(int i=1; i<=teams; i++) {
    (res *= mod_pow(i, MOD-2)) %= MOD;
  }
  int inv2 = mod_pow(2, MOD-2);
  for(int i=1; i<=teams; i++) {
    (res *= inv2) %= MOD;
  }
  return res;  
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());

  int ans = 1;  
  int idx = n-1;
  for(int i=0; i<n/2; i++){
    if(a[i]+a[i+1] <= k){
      int teams = (n - 2*i)/2;
      (ans *= calc(teams))%=MOD;
      break;
    }
    while(idx > i and a[i]+a[idx] <= k) idx--;
    if(idx == n-1){ans = 0; break;}
    int rem = n-idx-1;
    (ans *= rem-i) %= MOD;
  }  
  cout << ans << endl;
  
  return 0;
}


0