怎样找到黄页网站,陶瓷网站建设,深圳专业医疗网站建设,永久免费的网站哪个好总结
做的很坎坷。。。 一些细节上的玄学bug #xff08;上次也一样。。。#xff09; 还是要加强基础#xff01;#xff01;#xff01;
T1 x的实根
不贴了#xff0c;就是水题。。。
T2 二分查找
就是lowerbound
T3逆序对
1.树状数组 2.归并排序 注意#xff…总结
做的很坎坷。。。 一些细节上的玄学bug 上次也一样。。。 还是要加强基础
T1 x的实根
不贴了就是水题。。。
T2 二分查找
就是lowerbound
T3逆序对
1.树状数组 2.归并排序 注意
int q[N]{};这个隐含了一个On的初始化
代码
#includecstdio
#includecstring
#includecmath
#includealgorithm
#includeiostream
#define ll long long
using namespace std;
const int N1e5100;
const double epc0.00000000001;
int m,n;
int a[N];
ll num0;
void guibing(int st,int ed){if(sted) return;int mid(sted)1;guibing(st,mid);guibing(mid1,ed);
// printf(st%d,ed%d\n,st,ed);int p1st,p2mid1;int nm0;int q[N];while(p1midp2ed){if(a[p1]a[p2]){q[nm]a[p1];}else{q[nm]a[p2];nummid-p11;
// printf(dksfh\n);}
// printf(p1%d p2%d num%lld mid%d\n,p1,p2,num,mid);}while(p1mid){q[nm]a[p1];}while(p2ed){q[nm]a[p2];}for(int i1,plst;inm;i,pl){a[pl]q[i];}
// printf(\n);
}
int main(){scanf(%d,n);for(int i1;in;i) scanf(%d,a[i]);guibing(1,n);printf(%lld,num);return 0;
}
/*
4
3 2 3 2
*/#includecstdio
#includecstring
#includecmath
#includealgorithm
#includeiostream
#define ll long long
using namespace std;
const int N1e5100;
const double epc0.00000000001;
int m,n;
int a[N],b[N];
int tree[N];
ll ans;
bool cmp(int x,int y){return xy;
}
void add(int x){for(int ix;iN;ii(-i)){tree[i];
// printf(pl%d tree%d\n,i,tree[i]);}return;
}
int query(int x){int res0;
// printf(query------%d:\n,x);for(;x;x-x(-x)){restree[x];
// printf(pl%d res%d\n,x,res);}return res;
}
int main(){scanf(%d,n);for(int i1;in;i){scanf(%d,a[i]);b[i]a[i];}sort(b1,b1n);int numunique(b1,b1n)-b-1;for(int in;i1;i--){a[i]lower_bound(b1,b1num,a[i])-b;
// printf(ooooo%d:\n,a[i]);ansquery(a[i]-1);add(a[i]);}printf(%lld,ans);return 0;
}
/*
5
3 2 3 2 1
*/