洛谷传送门
虽然可以用归并排序求,但我实在记不住归并排序的代码。
还是树状数组和蔼点。
先离散化,树状数组就可以开小点,不过耗的时间多点。
——代码
1 #include <cstdio> 2 #include <algorithm> 3 #define lowbit(x) x & x 4 5 using namespace std; 6 7 int n, ans, sz; 8 int a[01], b[01], c[160000]; 9 10 inline void add(int x) 11 17 } 18 19 inline int sum(int x) 20 27 return tot; 28 } 29 30 int main() 31 43 printf("%d", ans); 44 return 0; 45 }View Code