比赛 |
EYOI与SBOI开学欢乐赛5th |
评测结果 |
AATTTTTTTT |
题目名称 |
积木游戏 |
最终得分 |
20 |
用户昵称 |
HeSn |
运行时间 |
8.000 s |
代码语言 |
C++ |
内存使用 |
4.59 MiB |
提交时间 |
2022-09-16 20:11:21 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n, m, a[110], b[110], c[110], ans;
void dfs(int x, int cs, int s, int la, int lb) {
if(cs > m || x > n + 1) {
return ;
}
// cout << s << endl;
ans = max(ans, s);
dfs(x + 1, cs, s, la, lb);
dfs(x + 1, cs + 1, s + c[x], a[x], b[x]);
dfs(x + 1, cs + 1, s + c[x], b[x], a[x]);
dfs(x + 1, cs + 1, s + b[x], a[x], c[x]);
dfs(x + 1, cs + 1, s + b[x], c[x], a[x]);
dfs(x + 1, cs + 1, s + a[x], b[x], c[x]);
dfs(x + 1, cs + 1, s + a[x], c[x], b[x]);
if(!cs) {
return ;
}
if(a[x] <= la && b[x] <= lb) {
dfs(x + 1, cs, s + c[x], a[x], b[x]);
}
if(b[x] <= la && a[x] <= lb) {
dfs(x + 1, cs, s + c[x], b[x], a[x]);
}
if(a[x] <= la && c[x] <= lb) {
dfs(x + 1, cs, s + b[x], a[x], c[x]);
}
if(c[x] <= la && a[x] <= lb) {
dfs(x + 1, cs, s + b[x], c[x], a[x]);
}
if(b[x] <= la && c[x] <= lb) {
dfs(x + 1, cs, s + a[x], b[x], c[x]);
}
if(c[x] <= la && b[x] <= lb) {
dfs(x + 1, cs, s + a[x], c[x], b[x]);
}
}
signed main() {
freopen("buildinggame.in", "r", stdin);
freopen("buildinggame.out", "w", stdout);
cin >> n >> m;
for(int i = 1; i <= n; i ++) {
cin >> a[i] >> b[i] >> c[i];
}
dfs(1, 0, 0, 0, 0);
cout << ans;
return 0;
}