結果

問題 No.412 花火大会
ユーザー kyuridenamidakyuridenamida
提出日時 2016-08-12 22:46:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 158,668 KB
実行使用メモリ 5,512 KB
最終ジャッジ日時 2023-08-07 12:37:43
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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;
	

	
	
	
}
0