版本比较
题解:P14400 [JOISC 2016] 回转寿司 / Sushi
正文
增加 2 行删除 2 行
30 行未改动3132333435353637383912 行未改动52535455565657585960217 行未改动全部展开30 行未改动2. **完整块**: - 将当前 $P$ 加入堆,弹出堆中最大值; - 块内元素的最大值被移除,剩余元素仍由堆维护就行。
总时间复杂度为 $O(Q \times \sqrt{N} \log N) \approx 3 \times 10^7$。总时间复杂度为 $\mathcal{O}(Q \times \sqrt{N} \log N) \approx 3 \times 10^7$。
:::success[代码]```cpp#include<bits/stdc++.h>12 行未改动int n, m, crush, a[N], L[M], R[M], val[N];priority_queue<int, vector<int>, less<int>> qp[M];priority_queue<int, vector<int>, greater<int>> qp2[M];signed main(){ read(n), read(m); read(n), read(m); crush = sqrt(n); for(int i = 1; i <= n; i++){ read(val[i]); a[i] = ceil(1.0 * i / crush);217 行未改动全部展开