题目链接
const LL INF = 1100000000000000000;const int MAXN = 110;struct Node{    int cost, Min, n;    int operator< (const Node& a) const    {        return Min < a.Min;    }} ipt[MAXN];LL dp[1100000];int main(){//    freopen("in.txt", "r", stdin);    int people, problem, percost;    while (~RIII(people, problem, percost))    {        int all = (1 << problem) - 1;        FE(i, 1, all) dp[i] = INF;        dp[0] = 0;        REP(i, people)        {            RII(ipt[i].cost, ipt[i].Min);            int n, t, v = 0;            RI(n);            REP(j, n)            {                RI(t);                v |= (1 << (t - 1));            }            ipt[i].n = v;        }        sort(ipt, ipt + people);        LL ans = INF;        REP(i, people)        {            FE(j, 0, all)            {                if ((ipt[i].n | j) == all)                {                    ans = min(ans, dp[j] + ipt[i].cost + (LL)percost * ipt[i].Min);                }            }            FED(j, all, 0)            {                int nxt = j | ipt[i].n;                dp[nxt] = min(dp[nxt], dp[j] + ipt[i].cost);            }        }        if (ans != INF)            cout << ans << endl;        else            puts("-1");    }    return 0;}
                        
                        HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号