結果

問題 No.794 チーム戦 (2)
ユーザー veqccveqcc
提出日時 2019-02-22 22:29:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 1,500 ms
コード長 1,045 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 97,788 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 03:18:08
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 91 ms
6,940 KB
testcase_15 AC 94 ms
6,940 KB
testcase_16 AC 96 ms
6,940 KB
testcase_17 AC 93 ms
6,940 KB
testcase_18 AC 89 ms
6,940 KB
testcase_19 AC 87 ms
6,940 KB
testcase_20 AC 92 ms
6,944 KB
testcase_21 AC 94 ms
6,940 KB
testcase_22 AC 57 ms
6,940 KB
testcase_23 AC 50 ms
6,944 KB
testcase_24 AC 38 ms
6,944 KB
testcase_25 AC 33 ms
6,944 KB
testcase_26 AC 36 ms
6,944 KB
testcase_27 AC 35 ms
6,940 KB
testcase_28 AC 35 ms
6,944 KB
testcase_29 AC 36 ms
6,944 KB
testcase_30 AC 30 ms
6,940 KB
testcase_31 AC 36 ms
6,944 KB
testcase_32 AC 35 ms
6,944 KB
testcase_33 AC 35 ms
6,940 KB
testcase_34 AC 35 ms
6,944 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