結果

問題 No.794 チーム戦 (2)
ユーザー face4face4
提出日時 2019-12-08 19:47:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 1,500 ms
コード長 1,143 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 75,380 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 03:34:37
合計ジャッジ時間 5,529 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 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 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 95 ms
4,376 KB
testcase_15 AC 96 ms
4,380 KB
testcase_16 AC 95 ms
4,376 KB
testcase_17 AC 89 ms
4,380 KB
testcase_18 AC 268 ms
4,376 KB
testcase_19 AC 265 ms
4,380 KB
testcase_20 AC 266 ms
4,376 KB
testcase_21 AC 266 ms
4,380 KB
testcase_22 AC 103 ms
4,376 KB
testcase_23 AC 59 ms
4,380 KB
testcase_24 AC 101 ms
4,376 KB
testcase_25 AC 91 ms
4,384 KB
testcase_26 AC 60 ms
4,376 KB
testcase_27 AC 71 ms
4,376 KB
testcase_28 AC 70 ms
4,380 KB
testcase_29 AC 34 ms
4,380 KB
testcase_30 AC 34 ms
4,380 KB
testcase_31 AC 209 ms
4,376 KB
testcase_32 AC 211 ms
4,376 KB
testcase_33 AC 143 ms
4,376 KB
testcase_34 AC 143 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    ll ans = 1, stock = 0, pos = -1;
    for(int i = n-1; i >= n/2; i--){
        int next = upper_bound(v.begin(), v.end(), k-v[i])-v.begin()-1;
        stock += next-pos;
        pos = next;
        if(stock == 0){
            cout << 0 << endl;
            return 0;
        }else if(pos >= i){
            int res = (i-n/2+1)*2;
            ll tmp = 1;
            while(res > 0){
                (tmp *= (ll)res*(res-1)%mod*modpow(2,mod-2)%mod*modpow(res/2,mod-2)%mod) %= mod;
                res -= 2;
            }
            (ans *= tmp) %= mod;
            break;
        }
        (ans *= stock--) %= mod;
    }
    cout << ans << endl;
    return 0;
}
0