ホームページ >ウェブフロントエンド >htmlチュートリアル >RCC 2014 ウォームアップ (ディビジョン 2)Cunning Gena_html/css_WEB-ITnose
質問リンク
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;}