【CodeForces 417D】【Cunning Gena】

来源:互联网 发布:矩阵通解 编辑:程序博客网 时间:2024/05/17 04:20

http://codeforces.com/problemset/problem/417/D


看来最近智商真的是出了大问题了,英语也读不懂了、


//#define _TEST _TEST#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <cmath>#include <algorithm>using namespace std;/************************************************Code By willinglive    Blog:http://willinglive.cf************************************************/#define rep(i,l,r) for(int i=l,___t=(r);i<=___t;i++)#define per(i,r,l) for(int i=r,___t=(l);i>=___t;i--)#define MS(arr,x) memset(arr,x,sizeof(arr))#define LL long long#define INE(i,u,e) for(int i=head[u];~i;i=e[i].next)inline const int read(){int r=0,k=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')k=-1;for(;c>='0'&&c<='9';c=getchar())r=r*10+c-'0';return k*r;}/////////////////////////////////////////////////const LL inf=((unsigned LL)0-1)>>1;int n,m; LL b;struct data{LL k;int x;int s;}a[102];LL dp[1<<20],ans;int all;/////////////////////////////////////////////////bool cmp(data p,data q){return p.k<q.k;}void cal(int k){rep(S,0,all){dp[S|a[k].s]=min(dp[S|a[k].s],dp[S]+a[k].x);}ans=min(ans,dp[all]+a[k].k*b);}/////////////////////////////////////////////////void input(){    n=read(); m=read(); b=read();    rep(i,1,n)    {    a[i].x=read();    a[i].k=read();    rep(j,1,read()) a[i].s|=1<<read()-1;    }    sort(&a[1],&a[n+1],cmp);}void solve(){    MS(dp,0x3f); dp[0]=0;    ans=((unsigned LL)0-1)>>1;    all=1<<m; all--;    rep(i,1,n) cal(i);    if(ans<inf/3) printf("%I64d\n",ans);    else puts("-1");}/////////////////////////////////////////////////int main(){    #ifndef _TEST    freopen("std.in","r",stdin); freopen("std.out","w",stdout);    #endif    input(),solve();    return 0;}


0 0