結果

問題 No.794 チーム戦 (2)
ユーザー veqccveqcc
提出日時 2019-02-22 22:29:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 1,500 ms
コード長 1,045 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 96,776 KB
実行使用メモリ 4,764 KB
最終ジャッジ日時 2023-08-16 19:52:48
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 84 ms
4,688 KB
testcase_15 AC 88 ms
4,632 KB
testcase_16 AC 85 ms
4,632 KB
testcase_17 AC 85 ms
4,576 KB
testcase_18 AC 83 ms
4,592 KB
testcase_19 AC 84 ms
4,752 KB
testcase_20 AC 81 ms
4,568 KB
testcase_21 AC 81 ms
4,764 KB
testcase_22 AC 50 ms
4,380 KB
testcase_23 AC 46 ms
4,380 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 35 ms
4,376 KB
testcase_27 AC 34 ms
4,580 KB
testcase_28 AC 34 ms
4,584 KB
testcase_29 AC 32 ms
4,592 KB
testcase_30 AC 26 ms
4,572 KB
testcase_31 AC 33 ms
4,588 KB
testcase_32 AC 32 ms
4,568 KB
testcase_33 AC 33 ms
4,568 KB
testcase_34 AC 32 ms
4,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0