結果

問題 No.412 花火大会
ユーザー kimiyukikimiyuki
提出日時 2016-09-29 22:47:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 70,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 07:51:45
合計ジャッジ時間 1,378 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
ll p(int n) { return 1ll << n; }
ll c(int n, int r) {
    ll acc = 1;
    repeat (i,r) acc *= n-i;
    repeat (i,r) acc /= i+1;
    return acc;
}
ll f(int n, int r) {
    ll acc = p(n);
    repeat (i,r) acc -= c(n,i);
    return acc;
}
int main() {
    // input
    int b, c, d; cin >> b >> c >> d;
    int n; cin >> n;
    vector<int> es(n); repeat (i,n) cin >> es[i];
    // compute
    array<int,4> e = {};
    repeat (i,n) {
        int cnt = 0;
        cnt += int(b <= es[i]);
        cnt += int(c <= es[i]);
        cnt += int(d <= es[i]);
        e[cnt] += 1;
    }
    ll ans = 0;
    ans += p(e[0]) * f(e[1], 1) * f(e[2], 1) * f(e[3], 1);
    ans += p(e[0]) * f(e[1], 1)              * f(e[3], 2);
    ans += p(e[0]) *              f(e[2], 2) * f(e[3], 1);
    ans += p(e[0]) *                e[2]     * f(e[3], 2);
    ans += p(e[0]) *                           f(e[3], 3);
    cout << ans << endl;
    return 0;
}
0