結果

問題 No.412 花火大会
ユーザー kyuridenamida
提出日時 2016-08-12 22:46:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 1,425 ms
コンパイル使用メモリ 172,760 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-11-07 16:34:51
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define int long long
map< array<int,4> ,int > dp;
int V[110];
int N;
int A,B,C;
tuple<int,int,int> f(int a,int b,int c,int p){
if( a < p ) return tuple<int,int,int>{p,a,b};
if( b < p ) return tuple<int,int,int>{a,p,b};
if( c < p ) return tuple<int,int,int>{a,b,p};
return tuple<int,int,int>{a,b,c};
}
int dfs(int x,int a,int b,int c){
// cout << x << " " << a << " " << b << " " << c << endl;
if( x == N ) return a >= A and b >= B and c >= C;
if( x >= N ) return 0;
if( dp.count({x,a,b,c}) ) return dp[{x,a,b,c}];
int X,y,z;
tie(X,y,z) = f(a,b,c,V[x]);
return dp[{x,a,b,c}] = dfs(x+1,X,y,z) + dfs(x+1,a,b,c);
}
signed main(){
//memset(dp,-1,sizeof(dp));
cin >> A >> B >> C;
if( A < B ) swap(A,B);
if( B < C ) swap(B,C);
if( A < B ) swap(A,B);
cin >> N;
for(int i = 0 ; i < N ; i++) cin >> V[i];
cout << dfs(0,0,0,0) << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0