QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-14 07:10:41

Last updated: 2025-12-14 07:10:45

Back to Problem

题解

假设 $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)$。

Comments

No comments yet.