結果

問題 No.412 花火大会
ユーザー cormorancormoran
提出日時 2016-09-29 23:24:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,689 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 168,796 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-13 15:00:17
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()

template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:

    vector<vector<ll>> C;
    ll Combination(int n, int k){
        if(C[n][k] >= 0) return C[n][k]; 
        if(k == 0 || k==n) return C[n][k] = 1;
        else return  C[n][k] = Combination(n-1, k-1) + Combination(n-1, k);
    }
    
    bool solve() {
        C.resize(101, vector<ll>(101, -1));
        vector<int> A(3); cin >> A;
        sort(all(A));
        reverse(all(A)); // dec
        int N; cin >> N;
        vector<int> E(N); cin >> E;

        if(N < 3) {
            cout << 0 << endl;
            return 0;
        }
        
        vector<int> a(4);
        for(int e : E) {
            rep(i, 3) if(A[i] <= e) a[i]++;
        }
        a[3] = N - a[2];
        a[2] -= a[1];
        a[1] -= a[0];
        
        ll ans = 0;
        rep(a0, a[0] + 1) {
            rep(a1, a[1] + 1) {
                rep(a2, a[2] + 1) {
                    rep(a3, a[3] + 1) {
                        if(a0 >= 1 and a0 + a1 >= 2 and a0 + a1 + a2 >= 3) {
                            ans += Combination(a[0], a0) * Combination(a[1], a1) * Combination(a[2], a2) * Combination(a[3], a3);
                        }
                    }
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0