记录编号 | 160027 | 评测结果 | AAAAAAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 守卫标志物 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 2.407 s | ||
提交时间 | 2015-04-23 17:32:43 | 内存使用 | 16.31 MiB | ||
#include<cstdio> #include<string.h> #include<iostream> using namespace std; typedef long long LL; LL N,H,w[1<<20]={0},SH[1<<20]={0},maxn=2e10,ans=-1; class miku { public: LL h,w,p; }cow[30]; int main() { freopen("guardc.in","r",stdin); freopen("guardc.out","w",stdout); scanf("%d%d",&N,&H); //cout<<N<<" "<<H<<endl; memset(w,-1,sizeof(w)); for(int i=0;i<N;i++) scanf("%d%d%d",&cow[i].h,&cow[i].w,&cow[i].p); w[0]=maxn; for(int i=1;i<(1<<N);i++) { for(int j=0;j<N;j++) { if((i>>j)&1) { int t=i^(1<<j); //cout<<t<<endl; if(cow[j].w>w[t]) continue; SH[i]=SH[t]+cow[j].h; w[i]=max(w[i],min(cow[j].p,w[t]-cow[j].w)); } } if(SH[i]>=H) { ans=max(w[i],ans); } } if(ans==-1) printf("Mark is too tall"); else printf("%d",ans); return 0; }