結果
問題 | No.1238 選抜クラス |
ユーザー | piddy |
提出日時 | 2020-09-06 08:03:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 5,190 bytes |
コンパイル時間 | 717 ms |
コンパイル使用メモリ | 76,288 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-05-06 20:39:23 |
合計ジャッジ時間 | 4,490 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
8,448 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
#include <iostream> #include <vector> #include <bitset> using namespace std; using ll = long long; template<long long P> long long modinv(long long n) { long long a = P, u = 1, v = 0; while (a) { long long t = n / a; n -= t * a; std::swap(n, a); u -= t * v; std::swap(u, v); } u %= P; if (u < 0) u += P; return u; } template<long long M> struct modint { long long val; modint<M>(long long right) : val(right) {sub(val);} modint<M>() {val = 0;} void sub(long long &n) { if (n < 0) { long long m = (-n) % M; n = M - m; } else n %= M; } modint<M> operator+ (modint<M> right) {return (this -> val) + right.val;} modint<M> operator+ (long long right) {sub(right); return (this -> val) + right;} modint<M> operator- (modint<M> right) {return (this -> val) - right.val;} modint<M> operator- (long long right) {sub(right); return (this -> val) - right;} modint<M> operator* (modint<M> right) {return (this -> val) * right.val;} modint<M> operator* (long long right) {sub(right); return (this -> val) * right;} bool operator== (modint<M> right) {return ((this -> val) == right.val);} bool operator== (long long right) {sub(right); return ((this -> val) == right);} bool operator!= (modint<M> right) {return ((this -> val) != right.val);} bool operator!= (long long right) {sub(right); return ((this -> val) != right);} bool operator<= (modint<M> right) {return ((this -> val) <= right.val);} bool operator<= (long long right) {sub(right); return ((this -> val) <= right);} bool operator>= (modint<M> right) {return ((this -> val) >= right.val);} bool operator>= (long long right) {sub(right); return ((this -> val) >= right);} bool operator< (modint<M> right) {return ((this -> val) < right.val);} bool operator< (long long right) {sub(right); return ((this -> val) < right);} bool operator> (modint<M> right) {return ((this -> val) > right.val);} bool operator> (long long right) {sub(right); return ((this -> val) > right);} void operator+= (modint<M> right) {*this = *this + right;} void operator+= (long long right) {*this = *this + right;} void operator-= (modint<M> right) {*this = *this - right;} void operator-= (long long right) {*this = *this - right;} void operator*= (modint<M> right) {*this = *this * right;} void operator*= (long long right) {*this = *this * right;} modint<M>& operator++ () {*this += 1; return *this;} modint<M> operator++ (int) {*this += 1; return *this - 1;} modint<M>& operator-- () {*this -= 1; return *this;} modint<M> operator-- (int) {*this -= 1; return *this + 1;} modint<M> operator/ (modint<M> right) {return *this * modinv<M>(right.val);} modint<M> operator/ (long long right) {sub(right); return *this * modinv<M>(right);} void operator/= (modint<M> right) {*this = *this / right;} void operator/= (long long right) {*this = *this / right;} }; std::vector<long long> factorial; std::vector<long long> factorial_inv; template<long long P> void make_table(long long n) { factorial.resize(n + 1, 1); factorial_inv.resize(n + 1, 1); for (long long i = 2; i <= n; i++) { factorial[i] = factorial[i - 1] * i % P; } factorial_inv[n] = modinv<P>(factorial[n]); for (long long i = n - 1; i >= 0; i--) { factorial_inv[i] = factorial_inv[i + 1] * (i + 1) % P; } } template<long long P> modint<P> permutation(long long n, long long r) { if (n <= factorial.size()) { modint<P> a = factorial[n], b = factorial_inv[n - r]; return a * b; } else { std::cerr << "attention : factorial table is not constructed" << '\n'; modint<P> ret = 1; for (long long i = 0; i < r; i++) ret *= n - i; return ret; } } template<long long P> modint<P> combination(long long n, long long r) { r = std::min(r, n - r); if (n <= factorial.size()) { return permutation<P>(n, r) * factorial_inv[r]; } else { std::cerr << "attention : factorial table is not constructed" << '\n'; modint<P> ret = 1; for (long long i = 0; i < r; i++) { ret *= n - i; ret /= i + 1; } return ret; } } template<long long M> modint<M> modpow(long long a, long long n) { a %= M; if (n == 0) return 1; if (a == 0) return 0; if (a == 1) return 1; long long b = 1, cnt = 0; while (b < M && cnt < n) { b *= a; cnt++; } modint<M> ret; if (b < M) ret = b; else { b %= M; ret = modpow<M>(b, n / cnt) * modpow<M>(a, n % cnt); } return ret; } template<long long M> modint<M> modpow(modint<M> m, long long n) { long long a = m.val; if (n == 0) return 1; if (a == 0) return 0; if (a == 1) return 1; long long b = 1, cnt = 0; while (b < M && cnt < n) { b *= a; cnt++; } modint<M> ret; if (b < M) ret = b; else { b %= M; ret = modpow<M>(b, n / cnt) * modpow<M>(a, n % cnt); } return ret; } template<long long M> std::ostream &operator<< (std::ostream &out, modint<M> tgt) {out << tgt.val; return out;} int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; const int P = 1000000007; modint<P> ans = 0; for (int i = 1; i < (1 << N); i++) { bitset<32> bs = i; int sum = 0; for (int j = 0; j < N; j++) { if (bs[j]) sum += A[j]; } if (sum >= K * __builtin_popcount(i)) ans++; } cout << ans << endl; }