結果

問題 No.412 花火大会
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-02 02:30:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 153,280 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 20:19:49
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.02 02:30:49
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int b,c,d;cin >> b >> c >> d;
    int n;cin >> n;
    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> tmp;
    tmp.push_back(b);
    tmp.push_back(c);
    tmp.push_back(d);
    sort(tmp.begin(), tmp.end());
    b = tmp[0];
    c = tmp[1];
    d = tmp[2];
    vector<int> e(n);
    for (int i = 0; i < n; i++) {
        cin >> e[i];
    }
    sort(e.begin(), e.end());
    // dp[i][j] : i番目まででj個つかう
    vector<vector<ll>> dp(n + 1,vector<ll>(4,0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        dp[i + 1][0] += dp[i][0] * 2;
        dp[i + 1][1] += dp[i][1];
        dp[i + 1][2] += dp[i][2];
        dp[i + 1][3] += dp[i][3];
        if (b <= e[i]) dp[i + 1][1] += dp[i][0];
        if (c <= e[i]) dp[i + 1][2] += dp[i][1];
        if (d <= e[i]) dp[i + 1][3] += dp[i][2];
    }
    cout << dp[n][3] << endl;
    return 0;
}
0