假设 $a_1\ge a_2\ge \cdots\ge a_n$,则能够满足当且仅当 $\sum_{i=1}^{k}a_i\le \sum_{j=1}^m\min\{b_j,k\}\pod{0\le k\le n}$。用线段树维护前缀最小值即可。
时间复杂度 $O(n+m+q\log n)$。
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.
Type: Editorial
Status: Open
Posted by: jiangly
Posted at: 2025-12-14 07:10:41
Last updated: 2025-12-14 07:10:45
假设 $a_1\ge a_2\ge \cdots\ge a_n$,则能够满足当且仅当 $\sum_{i=1}^{k}a_i\le \sum_{j=1}^m\min\{b_j,k\}\pod{0\le k\le n}$。用线段树维护前缀最小值即可。
时间复杂度 $O(n+m+q\log n)$。