调整一下可以发现最优方案一定是选择 $m_i$ 最大的若干个人 (这些人既可以选 $m_i$ 也可以 $p_i$) 以及剩下的人当中最小的几个 $p_i$。二分答案,枚举 $m_i$ 最大的若干个人,用堆维护最优方案即可。时间复杂度 $O(n\log^2n)$。
QOJ.ac
QOJ
As we are currently experiencing an overwhelming number of web requests for fetching user submissions, we have temporarily disabled the full submissions list. You must now be logged in to view submissions.
Discussion #314 for Problem #1654. Neo-Robin Hood
Type: Editorial
Status: Open
Posted by: jiangly
Posted at: 2025-12-14 07:02:59
Last updated: 2025-12-14 07:03:02
题解
Comments
No comments yet.