結果

問題 No.412 花火大会
ユーザー btkbtk
提出日時 2016-08-14 00:45:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 175,744 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-04-25 06:29:58
合計ジャッジ時間 4,494 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
19,968 KB
testcase_01 AC 30 ms
19,968 KB
testcase_02 AC 33 ms
19,968 KB
testcase_03 AC 31 ms
19,968 KB
testcase_04 AC 18 ms
20,096 KB
testcase_05 AC 64 ms
19,968 KB
testcase_06 AC 181 ms
19,968 KB
testcase_07 AC 168 ms
19,968 KB
testcase_08 AC 19 ms
19,968 KB
testcase_09 AC 22 ms
20,096 KB
testcase_10 AC 31 ms
19,968 KB
testcase_11 AC 51 ms
19,968 KB
testcase_12 AC 51 ms
19,968 KB
testcase_13 AC 50 ms
19,968 KB
testcase_14 AC 53 ms
19,968 KB
testcase_15 AC 51 ms
19,968 KB
testcase_16 AC 53 ms
20,096 KB
testcase_17 AC 51 ms
19,968 KB
testcase_18 AC 165 ms
19,968 KB
testcase_19 AC 177 ms
19,968 KB
testcase_20 AC 180 ms
19,968 KB
testcase_21 AC 176 ms
20,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int main(){
    int B,C,D,N;cin>>B>>C>>D>>N;
    vector<int> v({B,C,D});
    sort(v.begin(),v.end());
    B=v[0],C=v[1],D=v[2];
    VVV dp(101,VV(101,V(101,0)));
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        int e;cin>>e;
        VVV nxt=dp;
        for(int b=0;b<=100;b++)
            for(int c=b;c<=100;c++)
                for(int d=c;d<=100;d++){
                    if(d<=e)nxt[c][d][e]+=dp[b][c][d];
                    else if(c<=e)nxt[c][e][d]+=dp[b][c][d];
                    else if(b<=e)nxt[e][c][d]+=dp[b][c][d];
                    else nxt[b][c][d]+=dp[b][c][d];
                }
        swap(dp,nxt);
    }
    LL res=0;
    for(int b=B;b<=100;b++)
        for(int c=C;c<=100;c++)
            for(int d=D;d<=100;d++)
                res+=dp[b][c][d];
    cout<<res<<endl;
    return 0;
}
0