結果

問題 No.794 チーム戦 (2)
ユーザー ShibuyapShibuyap
提出日時 2020-09-19 01:18:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 1,500 ms
コード長 1,154 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 201,792 KB
実行使用メモリ 4,976 KB
最終ジャッジ日時 2023-09-04 17:06:45
合計ジャッジ時間 5,775 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 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 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 90 ms
4,936 KB
testcase_15 AC 90 ms
4,968 KB
testcase_16 AC 90 ms
4,928 KB
testcase_17 AC 90 ms
4,920 KB
testcase_18 AC 90 ms
4,860 KB
testcase_19 AC 89 ms
4,916 KB
testcase_20 AC 90 ms
4,884 KB
testcase_21 AC 89 ms
4,880 KB
testcase_22 AC 55 ms
4,376 KB
testcase_23 AC 49 ms
4,380 KB
testcase_24 AC 39 ms
4,376 KB
testcase_25 AC 32 ms
4,380 KB
testcase_26 AC 36 ms
4,376 KB
testcase_27 AC 35 ms
4,912 KB
testcase_28 AC 35 ms
4,912 KB
testcase_29 AC 35 ms
4,856 KB
testcase_30 AC 34 ms
4,916 KB
testcase_31 AC 35 ms
4,976 KB
testcase_32 AC 35 ms
4,972 KB
testcase_33 AC 35 ms
4,904 KB
testcase_34 AC 35 ms
4,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int n; cin >> n;
    int K; cin >> K;
    int a[n] = {};
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    ll ans = 1;
    const ll MOD = 1000000007;
    ll cnt = 0;
    ll l = 0;
    int f[n] = {};
    drep(i,n){
        int x = K - a[i];
        if(f[i] == 0){
            cnt++;
            f[i] = 1;
        }
        while(f[l] == 0){
            if(a[l] <= x){
                cnt++;
                f[l] = 1;
                l++;
            }else{
                break;
            }
        }
        ans *= cnt - 1;
        ans %= MOD;
        cnt -= 2;
        if(i == n/2) break;
    }

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