标签
- 全搜索、优先队列
题目地址
D - Cake 123
- https://atcoder.jp/contests/abc123/tasks/abc123_d
问题描述
The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows:
- The deliciousness of the cakes with 1-shaped candles are A 1 _1 1, A 2 _2 2, …, A X _X X.
- The deliciousness of the cakes with 2-shaped candles are B 1 _1 1, B 2 _2 2, …, B Y _Y Y.
- The deliciousness of the cakes with 3-shaped candles are C 1 _1 1, C 2 _2 2, …, C Z _Z Z.
Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.
There are X × \times × Y × \times × Z such ways to choose three cakes.
We will arrange these X × \times × Y × \times ×

本文解析了一道AtCoder竞赛题,涉及全排列和优先队列技巧,讲述了如何通过高效选择蛋糕组合来计算美味总和,并输出前K个结果。博主分享了多种快速算法实现,包括使用优先队列减少循环次数,适用于D级问题的优化策略。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



