結果
問題 | No.794 チーム戦 (2) |
ユーザー |
|
提出日時 | 2019-02-22 21:33:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 1,500 ms |
コード長 | 1,184 bytes |
コンパイル時間 | 1,891 ms |
コンパイル使用メモリ | 199,644 KB |
最終ジャッジ日時 | 2025-01-06 21:36:27 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))#define ALL(x) begin(x), end(x)using ll = long long;using namespace std;template <int32_t MOD>struct mint {int64_t value;mint() = default;mint(int64_t value_) : value(value_) {}inline mint<MOD> operator * (mint<MOD> other) const { int64_t c = this->value * int64_t(other.value) % MOD; return mint<MOD>(c < 0 ? c + MOD : c);}inline mint<MOD> & operator *= (mint<MOD> other) { this->value = this->value * int64_t(other.value) % MOD; if (this->value < 0) this->value += MOD; return *this; }};constexpr int MOD = 1e9 + 7;mint<MOD> solve(int n, ll k, vector<ll> a) {sort(ALL(a));mint<MOD> acc = 1;int l = 0;REP (i, n / 2) {int r = n - i - 1;while (l < r and a[l] + a[r] <= k) ++ l;if (l >= r) {acc *= n - 2 * i - 1;} else {acc *= l - i;}}return acc;}int main() {int n; ll k; cin >> n >> k;vector<ll> a(n);REP (i, n) cin >> a[i];cout << solve(n, k, a).value << endl;return 0;}