結果
問題 |
No.794 チーム戦 (2)
|
ユーザー |
![]() |
提出日時 | 2019-02-23 05:32:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 1,493 ms |
コンパイル使用メモリ | 171,160 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 15:37:06 |
合計ジャッジ時間 | 5,215 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 29 |
ソースコード
#include "bits/stdc++.h" using namespace std; const int MOD = 1e9+7; void solve() { int N, K; cin >> N >> K; vector<int> as(N); for (int i = 0; i < N; i++) cin >> as[i]; sort(as.begin(), as.end()); if (as.front() + as.back() > K) { cout << 0 << endl; return; } long ans = 1, res = N; for (int i = N-1; i >= 0; i--) { int a = as[i]; if (a*2 <= K) break; auto it = lower_bound(as.begin(), as.end(), K-a); ans *= (it-as.begin()+1); ans %= MOD; res-=2; } ans *= res*(res-1)/2; ans %= MOD; cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }