CodeForces 580D.Kefa and Dishes(状压DP)

傷城~ 2022-06-16 12:59 274阅读 0赞

D. Kefa and Dishes
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output

When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn’t want to order the same dish twice to taste as many dishes as possible.

Kefa knows that the i-th dish gives him ai units of satisfaction. But some dishes do not go well together and some dishes go very well together. Kefa set to himself k rules of eating food of the following type — if he eats dish x exactly before dish y (there should be no other dishes between x and y), then his satisfaction level raises by c.

Of course, our parrot wants to get some maximal possible satisfaction from going to the restaurant. Help him in this hard task!

Input
The first line of the input contains thr

发表评论

表情:
评论列表 (有 0 条评论,274人围观)

还没有评论,来说两句吧...

相关阅读

    相关 DP】简单环

    怎么办,感觉现在所谓 会 的算法都是云的 以为自己会,然后随便出一道题就不会 云玩家是吧 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好烦 好

    相关 Codeforces 1215E DP

    题意:给你一个序列,你可以交换序列中的相邻的两个元素,问最少需要交换多少次可以让这个序列变成若干个极大的颜色相同的子段。 思路:由于题目中的颜色种类很少,考虑状压DP。设dp

    相关 group dp

      应某些人要求,我把标签删掉了   这是一道好题。   一看$c<=16$果断状压,但是怎么压?   一个很显然的思路是,枚举上下两层的状态,每一层的状态极限有$C(c

    相关 dp(瞎BB)

    最近在写状压dp,写得不太顺利啊,抠很久才抠出来。可见如此之菜。 状态压缩dp(简称状压dp)是一种非常典型的动态规划,通常使用在NP问题的小规模求解中,虽然是指数