結果

問題 No.794 チーム戦 (2)
ユーザー pekempeypekempey
提出日時 2019-06-30 17:51:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 1,500 ms
コード長 1,342 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 172,052 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 15:26:15
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 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 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 42 ms
4,376 KB
testcase_15 AC 42 ms
4,380 KB
testcase_16 AC 42 ms
4,376 KB
testcase_17 AC 42 ms
4,376 KB
testcase_18 AC 42 ms
4,376 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 42 ms
4,380 KB
testcase_21 AC 42 ms
4,376 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 24 ms
4,376 KB
testcase_24 AC 19 ms
4,380 KB
testcase_25 AC 16 ms
4,380 KB
testcase_26 AC 18 ms
4,380 KB
testcase_27 AC 20 ms
4,376 KB
testcase_28 AC 19 ms
4,380 KB
testcase_29 AC 19 ms
4,380 KB
testcase_30 AC 19 ms
4,380 KB
testcase_31 AC 19 ms
4,376 KB
testcase_32 AC 20 ms
4,380 KB
testcase_33 AC 20 ms
4,376 KB
testcase_34 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;

const int MOD = 1000000007;

struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.rbegin(), A.rend());
  int cnt = 0;
  rep(i, N) cnt += A[i] * 2 > K;
  if (cnt > N/2) {
    cout << 0 << endl;
    return 0;
  }
  int k = N;
  mint ans = 1;
  rep(i, cnt) {
    while (k > 0 && A[k-1]+A[i] <= K) k--;
    ans *= max(0, (N-k)-i);
  }
  // N-cnt*2
  // f(x) = (x-1)*(x-3)*...*1
  for (int i = 1; i <= N-cnt*2-1; i += 2) {
    ans *= i;
  }
  cout << ans << '\n';
}
0