比赛 |
EYOI与SBOI开学欢乐赛5th |
评测结果 |
WWWWWWWWWW |
题目名称 |
积木游戏 |
最终得分 |
0 |
用户昵称 |
湖岸与夜与咸鱼 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-09-16 21:32:38 |
显示代码纯文本
// 河南省实验中学 高中 21级 关天泽
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define re register
const int INF = 0x3f3f3f3f;
using namespace std;
int n, m, a[105], b[105], c[105];
int dp[105][105][4];
int ans, lastans;
void change(int i, int j, int k){
int chang, kuan, gao;
if (k == 1) chang = a[i], kuan = b[i], gao = c[i];
if (k == 2) chang = a[i], kuan = c[i], gao = b[i];
if (k == 3) chang = b[i], kuan = c[i], gao = a[i];
// cout << chang << " " << kuan << " " << gao << endl;
// cout << a[i - 1] << " " << b[i - 1] << " " << c[i - 1] << endl;
// cout << dp[i - 1][j][1] << " " << dp[i - 1][j][2] << " " << dp[i - 1][j][3] << endl;
if (chang <= a[i - 1] && kuan <= b[i - 1]) dp[i][j][k] = max(dp[i - 1][j][1] + gao, dp[i][j][k]);
if (chang <= a[i - 1] && kuan <= c[i - 1]) dp[i][j][k] = max(dp[i - 1][j][2] + gao, dp[i][j][k]);
if (chang <= b[i - 1] && kuan <= c[i - 1]) dp[i][j][k] = max(dp[i - 1][j][3] + gao, dp[i][j][k]);
// cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl << endl;
}
int main(){
freopen("buildinggame.in", "r", stdin);
freopen("buildinggame.out", "w", stdout);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
for (int k = 1; k <= 3; k++)
dp[i][j][k] = -INF;
dp[0][0][1] = 0;
dp[0][0][2] = 0;
dp[0][0][3] = 0;
a[0] = INF, b[0] = INF, c[0] = INF;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= n; i++)
for (int j = i; j >= 1; j--)
for (int k = 1; k <= 3; k++){
if (i == j){
int gao;
if (k == 1) gao = c[i];
if (k == 2) gao = b[i];
if (k == 3) gao = a[i];
dp[i][j][k] = gao;
// cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl << endl;
continue;
}
change(i, j, k);
// cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl << endl;
}
// for (int i = 1; i <= n; i++){
// for (int j = 1; j <= m; j++){
// for (int k = 1; k <= 3; k++){
// cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
// }
// }
// }
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
for (int k = 1; k <= 3; k++)
ans = max(ans, dp[i][j][k]);
cout << ans;
return 0;
}