博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
归并排序(分治)
阅读量:6976 次
发布时间:2019-06-27

本文共 596 字,大约阅读时间需要 1 分钟。

#include
#include
using namespace std;typedef long long ll;#define N 500010ll a[N],b[N];ll n,ans;void merge_sort(ll x,ll y){ if (y-x>1) { ll m=x+(y-x)/2; ll p=x,q=m,i=x; merge_sort(x,m); merge_sort(m,y); while (p
=y||(p
<=a[q])) b[i++]=a[p++]; else { if (p
>n&&n!=0) { ans=0; for (ll i=0;i
>a[i]; merge_sort(0,n); cout << ans << endl; } return 0;}

 

转载于:https://www.cnblogs.com/lisijie/p/7683544.html

你可能感兴趣的文章
程序员的量化交易之路(25)--Cointrader之MarketData市场数据实体(12)
查看>>
使用 CAS 在 Tomcat 中实现单点登录
查看>>
Podfile 常见语法
查看>>
【原】YUI压缩与CSS media queries下的bug
查看>>
[AWK]使用AWK进行分割字符串以及截取字符串
查看>>
SiteMesh介绍
查看>>
form实现登陆操作
查看>>
SpriteBuilder中如何平均拉伸精灵帧动画的距离
查看>>
poj1330Nearest Common Ancestors 1470 Closest Common Ancestors(LCA算法)
查看>>
dojo从asp.net中获取json数据
查看>>
Android:problem opening wizard the selected wizard could not be started
查看>>
PostgreSQL md5 auth method introduce, with random salt protect
查看>>
【spring框架】spring整合hibernate初步
查看>>
JVM调优总结
查看>>
PostgreSQL 9.3 beta2 stream replication primary standby switchover bug?
查看>>
创业思维 - Qunar的故事
查看>>
STM32中GPIO的8种工作模式
查看>>
一分钟了解阿里云产品:先知计划
查看>>
Centos 7环境下源码安装PostgreSQL数据库
查看>>
推荐一款 Flutter Push 推送功能插件
查看>>