結果
| 問題 | No.794 チーム戦 (2) | 
| コンテスト | |
| ユーザー |  veqcc | 
| 提出日時 | 2019-02-22 22:29:29 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 92 ms / 1,500 ms | 
| コード長 | 1,045 bytes | 
| コンパイル時間 | 787 ms | 
| コンパイル使用メモリ | 99,560 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 09:45:27 | 
| 合計ジャッジ時間 | 3,182 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const ll MOD = 1000000007LL;
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector <ll> a(n);
    ll mx = 0LL;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    if (mx >= k) {
        cout << 0 << "\n";
        return 0;
    }
    sort(a.begin(), a.end());
    if (a[n/2-1] * 2 > k) {
        cout << 0 << "\n";
        return 0;
    }
    ll ans = 1LL;
    int i;
    for (i = 0; i < n/2; i++) {
        if (a[n-i-1] * 2 <= k) break;
        int idx = lower_bound(a.begin(), a.end(), k - a[n-i-1]+1) - a.begin();
        ans = ans * (ll)(idx - i) % MOD;
    }
    int remain = n - i * 2;
    while (remain) {
        ans = ans * (remain - 1) % MOD;
        remain -= 2;
    }
    cout << ans << "\n";
    return 0;
}
            
            
            
        