結果

問題 No.794 チーム戦 (2)
ユーザー rtia_iidx
提出日時 2019-02-23 10:26:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 1,500 ms
コード長 912 bytes
コンパイル時間 1,050 ms
コンパイル使用メモリ 104,312 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 21:23:39
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    ll ans = 1;
    ll usenum = 0;

    for(int i = n-1; i >= n/2; i--){
        auto itr = upper_bound(a.begin(),a.end(),k - a[i]);
        ll oknum = itr - a.begin();
        if(oknum > i){
            oknum = i;
        }
        ans = (ans * (oknum-usenum++))%MOD;
    }

    cout << ans << endl;
    
    return 0;
}
0