摘要:
给定一个按照升序排列的长度为n 的整数数组,对于每个查询,返回改元素的起始位置和终止位置。 如果数组中不存在该元素,则返回 {-1, -1}。 #include <iostream> using namespace std; int a[100010]; int n, q; int BF1 (int 阅读全文
posted @ 2022-11-30 20:32
!&&||
阅读(44)
评论(0)
推荐(0)
摘要:
给定一个长度为 n的整数数列,计算数列中的逆序对的数量。 #include <iostream> using namespace std; const int N = 100010; int n, a[N]; long long sort (int l, int r) { if (l >= r) r 阅读全文
posted @ 2022-11-30 20:29
!&&||
阅读(33)
评论(0)
推荐(0)
摘要:
给定一个长度为 n 的整数数列,以及一个整数 k,请用快速选择算法求出数列从小到大排序后的第 k 个数。 #include <iostream> using namespace std; const int N = 100010; int a[N], n, k; int sort (int l, i 阅读全文
posted @ 2022-11-30 20:23
!&&||
阅读(38)
评论(0)
推荐(0)

浙公网安备 33010602011771号