結果

問題 No.794 チーム戦 (2)
ユーザー fooractalfooractal
提出日時 2019-02-22 22:36:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,486 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 94,960 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-04 03:43:44
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
using namespace std;

using int64 = long long;
using int128 = __int128;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

const int64 mod = 1e9 + 7;

int64 powMod(int64 a, int64 b) {
  int64 res = 1,
        p = a % mod;
  while (b > 0) {
    if (b & 1) (res *= p) %= mod;
    (p *= p) %= mod;
    b >>= 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  int64 K;
  cin >> N >> K;

  vector<int64> A(N);
  repeat (i, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  vector<int64> factorial(N + 1, 1);
  for (int i = 2; i <= N; i++) {
    factorial[i] = (i * factorial[i - 1]) % mod;
  }

  int64 ub = 0,
        ans = 1;
  for (int i = N - 1; i > ub; i--) {
    while (ub < i and A[i] + A[ub] <= K) ub++;

    if (i == ub) {
      // 残りは2i-N+2個
      int num = 2 * i - N + 2;
      (ans *= (factorial[num] * powMod(powMod(2, mod - 2), num / 2)) % mod) %= mod;
      (ans *= powMod(factorial[num / 2], mod - 2)) %= mod;
      break;
    } else {
      (ans *= max(0LL, ub - (N - 1 - i))) %= mod;
    }
  }
  cout << ans << endl;

  return 0;
}

0