比赛 |
20151028a |
评测结果 |
AAAWWAWAAWAWAAAWWAWWWWAWWAWWAWTTTWWWWWWWWWWWWTTTTEEEEEEEEEEETTTTTTTTTTTTTTTTTTTTTTTTTTTTTT |
题目名称 |
有趣的有趣的家庭菜园 |
最终得分 |
15 |
用户昵称 |
Binary10 |
运行时间 |
41.982 s |
代码语言 |
C++ |
内存使用 |
0.33 MiB |
提交时间 |
2015-10-28 11:46:35 |
显示代码纯文本
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cctype>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 1000;
int h[maxn], p[maxn], c[maxn], a[maxn], n;
int main()
{
freopen("Fgarden.in", "r", stdin);
freopen("Fgarden.out", "w", stdout);
cin >> n;
for(int i = 0; i < n; i++)
scanf("%d%d%d", &h[i], &p[i], &c[i]);
int ans = 0;
for(int i = 0;i < (1 << n); i++){
int m = 0, t = 0;
for(int j = 0; j < n; j++)
if(i & (1 << j)) a[m++] = j;
else t -= c[j];
for(int j = 0; j < m; j++){
bool ok = true;
for(int k = 0; k < j; k++)
if(h[a[k]] > h[a[j]]){
ok = false;
break;
}
if(!ok){
ok = true;
for(int k = j + 1; k < m; k++)
if(h[a[k]] > h[a[j]]){
ok = false;
break;
}
if(ok) t += p[a[j]];
}
else t += p[a[j]];
}
if(t > ans) ans = t;
}
cout << ans << endl;
return 0;
}