当前位置: 首页 > news >正文

【HDU 1394】Minimum Inversion Number 【线段树 训练2】

Problem Description
The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.

For a given sequence of numbers a1, a2, …, an, if we move the first m >= 0 numbers to the end of the seqence, we will obtain another sequence. There are totally n such sequences as the following:

a1, a2, …, an-1, an (where m = 0 - the initial seqence)
a2, a3, …, an, a1 (where m = 1)
a3, a4, …, an, a1, a2 (where m = 2)

an, a1, a2, …, an-1 (where m = n-1)

You are asked to write a program to find the minimum inversion number out of the above sequences.

Input
The input consists of a number of test cases. Each case consists of two lines: the first line contains a positive integer n (n <= 5000); the next line contains a permutation of the n integers from 0 to n-1.

Output
For each case, output the minimum inversion number

相关文章:

  • 【Windows编程】Step.2 消息循环机制
  • 【CDOJ 1334】 郭大侠与Rabi-Ribi
  • 【CDOJ 1074】秋实大哥搞算术【栈计算表达式】
  • 【CDOJ 1329】卿学姐与魔法
  • C++ STL 之 BitSet
  • [CDOJ 1343] 卿学姐失恋了
  • 【CDOJ 1342】郭大侠与甲铁城 【离线树状数组】
  • 【CDOJ 1350】卿学姐失恋了Ⅱ
  • 【CDOJ】柱爷与咸鱼神功
  • 【CDOJ 1357】柱爷与最大区间和
  • 【CDOJ 1323】柱爷的下凡
  • 【CDOJ 1321】柱爷的恋爱
  • 【CDOJ 1355】柱爷与三叉戟不得不说的故事 【状压DP+子集枚举】
  • [NOIP2011DAY1P1]铺地毯
  • 【vijos 1116】【codevs 1038】一元三次方程求解
  • [ 一起学React系列 -- 8 ] React中的文件上传
  • 【剑指offer】让抽象问题具体化
  • Android 控件背景颜色处理
  • java架构面试锦集:开源框架+并发+数据结构+大企必备面试题
  • Vue 动态创建 component
  • 不发不行!Netty集成文字图片聊天室外加TCP/IP软硬件通信
  • 番外篇1:在Windows环境下安装JDK
  • 浮动相关
  • 复习Javascript专题(四):js中的深浅拷贝
  • 函数式编程与面向对象编程[4]:Scala的类型关联Type Alias
  • 基于 Babel 的 npm 包最小化设置
  • 理解在java “”i=i++;”所发生的事情
  • 那些被忽略的 JavaScript 数组方法细节
  • 手机端车牌号码键盘的vue组件
  • 一道面试题引发的“血案”
  • 异常机制详解
  • 追踪解析 FutureTask 源码
  • 你对linux中grep命令知道多少?
  • ​LeetCode解法汇总1410. HTML 实体解析器
  • ​第20课 在Android Native开发中加入新的C++类
  • ​人工智能之父图灵诞辰纪念日,一起来看最受读者欢迎的AI技术好书
  • ## 临床数据 两两比较 加显著性boxplot加显著性
  • #pragma data_seg 共享数据区(转)
  • #Ubuntu(修改root信息)
  • $(selector).each()和$.each()的区别
  • (2)关于RabbitMq 的 Topic Exchange 主题交换机
  • (pojstep1.1.2)2654(直叙式模拟)
  • (保姆级教程)Mysql中索引、触发器、存储过程、存储函数的概念、作用,以及如何使用索引、存储过程,代码操作演示
  • (二)基于wpr_simulation 的Ros机器人运动控制,gazebo仿真
  • (附源码)计算机毕业设计ssm基于Internet快递柜管理系统
  • (黑马C++)L06 重载与继承
  • (离散数学)逻辑连接词
  • (七)Java对象在Hibernate持久化层的状态
  • (企业 / 公司项目)前端使用pingyin-pro将汉字转成拼音
  • (十六)Flask之蓝图
  • (实战)静默dbca安装创建数据库 --参数说明+举例
  • (一)使用IDEA创建Maven项目和Maven使用入门(配图详解)
  • (转)淘淘商城系列——使用Spring来管理Redis单机版和集群版
  • ***测试-HTTP方法
  • **CI中自动类加载的用法总结