結果
問題 | No.794 チーム戦 (2) |
ユーザー | Pachicobue |
提出日時 | 2019-02-22 22:08:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 103 ms / 1,500 ms |
コード長 | 9,261 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 209,864 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-25 08:42:25 |
合計ジャッジ時間 | 5,060 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 101 ms
5,248 KB |
testcase_15 | AC | 103 ms
5,248 KB |
testcase_16 | AC | 99 ms
5,248 KB |
testcase_17 | AC | 99 ms
5,248 KB |
testcase_18 | AC | 99 ms
5,248 KB |
testcase_19 | AC | 99 ms
5,248 KB |
testcase_20 | AC | 99 ms
5,248 KB |
testcase_21 | AC | 98 ms
5,248 KB |
testcase_22 | AC | 61 ms
5,248 KB |
testcase_23 | AC | 55 ms
5,248 KB |
testcase_24 | AC | 43 ms
5,248 KB |
testcase_25 | AC | 36 ms
5,248 KB |
testcase_26 | AC | 39 ms
5,248 KB |
testcase_27 | AC | 39 ms
5,248 KB |
testcase_28 | AC | 41 ms
5,248 KB |
testcase_29 | AC | 41 ms
5,248 KB |
testcase_30 | AC | 40 ms
5,248 KB |
testcase_31 | AC | 40 ms
5,248 KB |
testcase_32 | AC | 40 ms
5,248 KB |
testcase_33 | AC | 41 ms
5,248 KB |
testcase_34 | AC | 40 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> // https://yukicoder.me/problems/no/794 //!===========================================================!// //! dP dP dP !// //! 88 88 88 !// //! 88aaaaa88a .d8888b. .d8888b. .d888b88 .d8888b. 88d888b. !// //! 88 88 88ooood8 88' `88 88' `88 88ooood8 88' `88 !// //! 88 88 88. ... 88. .88 88. .88 88. ... 88 !// //! dP dP `88888P' `88888P8 `88888P8 `88888P' dP !// //!===========================================================!// using ld = long double; using ll = long long; std::mt19937 mt{std::random_device{}()}; template <typename F> constexpr F PI() { return 3.1415926535897932385; } template <typename T, std::size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename T, typename A> std::ostream& operator<<(std::ostream& os, const std::deque<T, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename K, typename T, typename C, typename A> std::ostream& operator<<(std::ostream& os, const std::multimap<K, T, C, A>& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template <typename T, typename C, typename A> std::ostream& operator<<(std::ostream& os, const std::multiset<T, C, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename K, typename T, typename C, typename A> std::ostream& operator<<(std::ostream& os, const std::map<K, T, C, A>& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) { return (os << "<" << v.first << "," << v.second << ">"); } template <typename T1, typename T2, typename T3> std::ostream& operator<<(std::ostream& os, const std::priority_queue<T1, T2, T3>& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::queue<T1>& v) { auto q = v; os << "["; while (not q.empty()) { os << q.front() << ",", q.pop(); } return os << "]\n"; } template <typename T, typename C, typename A> std::ostream& operator<<(std::ostream& os, const std::set<T, C, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::stack<T1>& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template <typename K, typename T, typename H, typename P, typename A> std::ostream& operator<<(std::ostream& os, const std::unordered_multimap<K, T, H, P, A>& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template <typename T, typename H, typename P, typename A> std::ostream& operator<<(std::ostream& os, const std::unordered_multiset<T, H, P, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename K, typename T, typename H, typename P, typename A> std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, T, H, P, A>& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template <typename T, typename H, typename P, typename A> std::ostream& operator<<(std::ostream& os, const std::unordered_set<T, H, P, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template <typename T, typename A> std::ostream& operator<<(std::ostream& os, const std::vector<T, A>& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } #define show(x) std::cerr << #x << " = " << (x) << std::endl //!========================================================!// //! 8888ba.88ba dP dP dP !// //! 88 `8b `8b 88 88 88 !// //! 88 88 88 .d8888b. .d888b88 88 88d888b. d8888P !// //! 88 88 88 88' `88 88' `88 88 88' `88 88 !// //! 88 88 88 88. .88 88. .88 88 88 88 88 !// //! dP dP dP `88888P' `88888P8 dP dP dP dP !// //!========================================================!// template <typename T, T mod> class ModInt { private: T value; static T pow(const T p, const T n) { return p < 0 ? pow(mod + p, n) : n == 0 ? 1 : n % 2 == 1 ? pow(p, n - 1) * p % mod : pow(p * p % mod, n / 2); } static T inv(const T p) { return pow(p, mod - 2); } public: ModInt() : value{0} {} ModInt(const T val) : value{((val % mod) + mod) % mod} {} ModInt(const ModInt<T, mod>& n) : value{n()} {} ModInt<T, mod>& operator=(const ModInt<T, mod>& n) { return value = n(), (*this); } ModInt<T, mod>& operator=(const T v) { return value = (mod + v % mod) % mod, (*this); } ModInt<T, mod> operator+() const { return *this; } ModInt<T, mod> operator-() const { return ModInt{mod - value}; } ModInt<T, mod> operator+(const ModInt<T, mod>& val) const { return ModInt{value + val()}; } ModInt<T, mod> operator-(const ModInt<T, mod>& val) const { return ModInt{value - val() + mod}; } ModInt<T, mod> operator*(const ModInt<T, mod>& val) const { return ModInt{value * val()}; } ModInt<T, mod> operator/(const ModInt<T, mod>& val) const { return ModInt{value * inv(val())}; } ModInt<T, mod>& operator+=(const ModInt<T, mod>& val) { return (((value += val()) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator-=(const ModInt<T, mod>& val) { return (((value -= val()) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator*=(const ModInt<T, mod>& val) { return (((value *= val()) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator/=(const ModInt<T, mod>& val) { return (((value *= inv(val())) %= mod) += mod) %= mod, (*this); } ModInt<T, mod> operator+(const T val) const { return ModInt{value + val}; } ModInt<T, mod> operator-(const T val) const { return ModInt{value - val}; } ModInt<T, mod> operator*(const T val) const { return ModInt{value * val}; } ModInt<T, mod> operator/(const T val) const { return ModInt{value * inv(val)}; } ModInt<T, mod>& operator+=(const T val) { return (((value += val) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator-=(const T val) { return (((value -= val) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator*=(const T val) { return (((value *= val) %= mod) += mod) %= mod, (*this); } ModInt<T, mod>& operator/=(const T val) { return (((value *= inv(val)) %= mod) += mod) %= mod, (*this); } bool operator==(const ModInt<T, mod>& val) const { return value == val.value; } bool operator!=(const ModInt<T, mod>& val) const { return not(*this == val); } bool operator==(const T val) const { return value == (mod + val % mod) % mod; } bool operator!=(const T val) const { return not(*this == val); } T operator()() const { return value; } }; template <typename T, T mod> inline ModInt<T, mod> operator+(const T val, const ModInt<T, mod>& n) { return ModInt<T, mod>{n() + val}; } template <typename T, T mod> inline ModInt<T, mod> operator-(const T val, const ModInt<T, mod>& n) { return ModInt<T, mod>{-n() + val}; } template <typename T, T mod> inline ModInt<T, mod> operator*(const T val, const ModInt<T, mod>& n) { return ModInt<T, mod>{n() * val}; } template <typename T, T mod> inline ModInt<T, mod> operator/(const T val, const ModInt<T, mod>& n) { return ModInt<T, mod>(val) / n; } template <typename T, T mod> inline bool operator==(const T val, const ModInt<T, mod>& n) { return n == val; } template <typename T, T mod> inline bool operator!=(const T val, const ModInt<T, mod>& n) { return not(val == n); } template <typename T, T mod> inline std::istream& operator>>(std::istream& is, ModInt<T, mod>& n) { T v; return is >> v, n = v, is; } template <typename T, T mod> std::ostream& operator<<(std::ostream& os, const ModInt<T, mod>& n) { return (os << n()); } template <int mod> using mint = ModInt<int, mod>; template <ll mod> using mll = ModInt<ll, mod>; constexpr ll MOD = 1000000007; int main() { int N; ll K; std::cin >> N >> K; std::vector<ll> A(N); for (int i = 0; i < N; i++) { std::cin >> A[i]; } std::sort(A.begin(), A.end()); mll<MOD> ans = 1; for (int i = N - 1; i >= N / 2; i--) { const ll R = K - A[i]; int sup = std::upper_bound(A.begin(), A.end(), R) - A.begin(); sup = std::min(sup, i); ans *= (sup - (N - i - 1)); } std::cout << ans << std::endl; return 0; }