【正经题解】区间排序
2025-11-29 13:46:48
发布于:浙江
22阅读
0回复
0点赞
妄图盗我账号的:@priority queue
题目大意
给你 次排序区间 ,你要把 到 的所有元素进行升序排序。最后输出排序的结果
直接模拟就行。
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a;
while(n--){
int l;
cin >> l;
a.push_back(l);
}int t;
cin >>t;
while(t--){
int x,y;
cin >> x >> y;
x--,y--;
sort(a.begin()+x,a.begin()+y+1);
}for(auto i:a)cout << i << " ";
return 0;
}
时间复杂度: ,其中排序复杂度为 ,一共 次询问。
空间复杂度:
这里空空如也







有帮助,赞一个