結果

問題 No.1045 直方体大学
ユーザー chocoruskchocorusk
提出日時 2020-05-01 22:09:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,371 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 126,568 KB
実行使用メモリ 15,952 KB
最終ジャッジ日時 2023-08-26 14:06:16
合計ジャッジ時間 3,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
15,640 KB
testcase_01 AC 4 ms
15,604 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 5 ms
15,668 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 5 ms
15,740 KB
testcase_18 AC 476 ms
15,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	int a[17], b[17], c[17];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];
	int dp[48][1<<16]={};
	for(int i=0; i<n; i++){
		dp[i][1<<i]=a[i];
		dp[i+n][1<<i]=b[i];
		dp[i+2*n][1<<i]=c[i];
	}
	int ans=0;
	for(int i=1; i<(1<<n); i++){
		for(int j=0; j<3*n; j++){
			int t=j%n;
			if(!dp[j][i]) continue;
			ans=max(ans, dp[j][i]);
			int x1, y1;
			if(j<n) x1=b[t], y1=c[t];
			else if(j<2*n) x1=a[t], y1=c[t];
			else x1=a[t], y1=b[t];
			for(int k=0; k<3*n; k++){
				int u=k%n;
				if(i&(1<<u)) continue;
				int x2, y2, z2;
				if(k<n) x2=b[u], y2=c[u], z2=a[u];
				else if(k<2*n) x2=a[u], y2=c[u], z2=b[u];
				else x2=a[u], y2=b[u], z2=a[u];
				if((x1>=x2 && y1>=y2) || (x1>=y2 && y1>=x2)){
					dp[k][i^(1<<u)]=max(dp[k][i^(1<<u)], dp[j][i]+z2);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
0