結果
| 問題 | No.794 チーム戦 (2) | 
| コンテスト | |
| ユーザー |  t33f | 
| 提出日時 | 2019-02-22 22:08:40 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 94 ms / 1,500 ms | 
| コード長 | 642 bytes | 
| コンパイル時間 | 619 ms | 
| コンパイル使用メモリ | 69,624 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 08:43:36 | 
| 合計ジャッジ時間 | 2,991 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
#include <algorithm>
#include <iostream>
using namespace std;
constexpr int M = 1000000007;
int main() {
    int n, k; cin >> n >> k;
    int a[n];for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    long long ans = 1;
    int i = 0, j = n-1;
    while (i < j) {
        while (i < j && a[i] + a[j] <= k) i++;
        if (i < n - j) { cout << 0 << endl; return 0; }
        ans = ans * (i - (n - j - 1)) % M;
        j--;
        // cerr << i << ' ' << j << ' ' << ans << endl;
    }
    int m = (j + 1 - (n - j - 1)) / 2;
    // cerr << m << endl;
    while (m > 0) { ans = ans * (2 * m - 1) % M; m--; }
    cout << ans << endl;
}
            
            
            
        