Frosh Week HDU - 3743

使用 Cadence ams 仿真器 对 混合信号电路 进行仿真 文章目录Cadence 基于ams仿真器的混合信号电路仿真建立数字(Digital)模块建立 Analog - Digital 混合仿真原理图建立 Analog - Digital 混合仿真config文件配置混合信号电路仿真环境针对混合信号电路demo进行仿真 Cadence 基于ams仿真器的混合信号电路仿真 你好,这里是一篇关于使用 Cadence 软件通过 ams 仿真器对混合信号电路(D... 阅读详情

题目:

During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are then asked to arrange themselves according to some criterion, such as their height, their birth date, or their student number. This rearrangement of the line must be accomplished only by successively swapping pairs of consecutive students. The team that finishes fastest wins. Thus, in order to win, you would like to minimize the number of swaps required.

Input

The first line of input contains one positive integer n, the number of students on the team, which will be no more than one million. The following n lines each contain one integer, the student number of each student on the team. No student number will appear more than once. 

Output

Output a line containing the minimum number of swaps required to arrange the students in increasing order by student number. 

Sample Input

3
3
1
2

Sample Output

2

 

题意:

给出一些数,问把这些数从小到大排序需要交换的最少次数;

 

思路:

利用归并排序求逆序数;

转:图解归并排序

 

代码:

#include<stdio.h>
int a[1008611],b[1008611];
long long sum;
void mergee(int c[],int first,int mid,int last,int d[])
{
    int i=first,j=mid+1,k=first;
    while(i<=mid&&j<=last)
    {
        if(c[i]<c[j])
            d[k++]=c[i++];
        else
        {
            d[k++]=c[j++];
            sum=sum+mid-i+1;
        }
    }
    if(i==mid+1)
        for(;j<=last;j++)
            d[k++]=c[j];
    else
        for(;i<=mid;i++)
            d[k++]=c[i];
    for(int t=first;t<=last;t++)
        c[t]=d[t];
}
void bottomupsort(int c[],int first,int last,int d[])
{
    if(first<last)
    {
        int mid=(first+last)/2;
        bottomupsort(c,first,mid,d);
        bottomupsort(c,mid+1,last,d);
        mergee(c,first,mid,last,d);
    }
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        sum=0;
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        bottomupsort(a,1,n,b);
        printf("%lld\n",sum);
    }
    return 0;
}

 

【YOLO11[基础]】分类任务的热力图可视化实践 | 论文必备 | 分类任务 | 即插即用 | 可选GradCAMPlusPlus, GradCAM, XGradCAM, EigenCAM, HiR 【YOLO11[基础]】分类任务的热力图可视化实践 | 论文必备 | 分类任务 | 即插即用 | 可选GradCAMPlusPlus, GradCAM, XGradCAM, EigenCAM, HiResCAM, LayerCAM, RandomCAM, EigenGradCAM等 阅读详情

相关推荐

极速建站!用1Panel面板一键部署Halo博客的保姆级教程 | 企业官网/个人博客搭建教程

个人博客是一种在互联网上发布自己的文章、图片、视频等内容的平台,通常以文字为主要形式,但也可以包含其他媒体。个人博客的用途非常广泛。它可以用来记录博主的日常生活、分享自己的知识和经验、展示自己的作品和技能,以及交流自己的观点和看法。通过个人博客,博主可以与读者建立联系,分享自己的见解和体验,同时也可以从读者那里获得反馈和建议。

zeruns的博客 1836

HDUOJ---3743Frosh Week(BIT+离散化)

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1545    Accepted Submission(s): 497 Problem Description During Frosh Week, student...

weixin_34096182的博客 524

RK3588上跑通Zipformer语音识别的3个坑与填坑实录(附完整编译命令)

本文详细记录了在RK3588开发板上部署Zipformer语音识别模型时遇到的三个典型问题及其解决方案,包括静态库版本冲突、编译脚本配置错误以及模型转换精度调优。文章提供了完整的编译命令和实战步骤,帮助开发者快速在边缘设备上实现高效的语音识别应用。

l6m7n8的博客 719

UVa11858 - Frosh Week(树状数组求逆序数)

During Frosh Week, students play various fun games to get to know eachother and compete against other teams. In one such game, all the froshon a team stand in a line, and are then asked to arrange the

多看多听多总结 1172

论文阅读笔记--Grid Anchor based Image Cropping: A New Benchmark and An Efficient Model

基于网格锚的图片裁剪:一种新的标准和高效的模型摘要1.介绍2.相关工作2.1 图像裁剪数据集和评估指标 摘要 图像裁剪的目的是通过去除图像中无关的内容来改善图像的组成和美学质量。现有的图像裁剪数据库大多只提供一个或多个人工标注的边界框作为基准,难以反映实际中图像裁剪的非唯一性和灵活性。 采用IoU等评价指标也不能可靠地反映裁剪模型的真实性能。本文回顾了图像裁剪的问题,并通过考虑图像裁剪的特殊特性和要求(如局部冗余、内容保存、高宽比),提出了基于网格锚的公式。 我们的公式将候选裁剪窗口的搜索空间从数百万减少到

qq_22565865的博客 2953

RTKlib操作手册--使用样例数据演示

本文将使用样例数据演示如何使用RTKLIB进行rtk差分定位。

samur2的博客 7804

Frosh Week (hdu 3743 树状数组)

Frosh Week

残阳止水 770

VMware Converter 6.2.0保姆级教程:从物理机到ESXi主机的完整迁移指南(含常见错误排查)

本文提供VMware Converter 6.2.0从物理机迁移至ESXi主机的完整保姆级教程。详细解析了迁移前的环境规划、核心转换过程步骤、版本差异对比,并重点针对代理安装失败、任务卡顿、虚拟机无法启动等常见错误提供了实战排查与解决方案,确保P2V迁移顺利进行。

sam99的博客 388

Frosh Week

Problem Description During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are th

Mr lebron的博客 924

自己动手写CPU(1)五级流水线及CPU第一条指令ori

自己动手写CPU(1)五级流水线及CPU第一条指令ori 动机 不知为何研一的自由时间突然多起来,可能人一闲下来就容易焦虑吧,hhhhhh。正好之前看到一本《自己动手写CPU》,就按照此书从头实做一遍MIPS指令集的CPU,也当做对大学课程的总结。之前看龙芯杯比赛的代码震惊到我了,想想那堆大佬本科在搞这东西而我本科在瓜瓜地刷分,感叹人之间的差距真的好大。痛定思痛,还是先动手做起来这才能假意安慰自己,我好像也不错。闲言少叙,让我们开始吧! 由于作者提供了各章实现的具体代码,所以该系列博客主要记录我过程中有哪些

谦豫 7087

XCP详解「3.1·ASAP2新建A2L文件」

后面是ASAP2新建A2L的操作步骤,如果是APE中新建的A2L就无需以下操作,APE只需要导入现成的A2L即可。退出点击保存时会提示保存A2L文件,是因为前面导出的是1.70版本,工程最低1.71,可以另外起个名字即可。导入elf文件,elf路径建议直接索引编译生成的Debug下的,防止编译后忘记更新。导出V1.70格式A2L文件,APE17支持V1.70。通过ASAP2生成需要A2L文件更常用些。同一个信号可以创建不同属性量。ASAP2中新建A2L文件。设置标定信号数量最大值。XCP详解「总目录」

光明磊学习&积累的地方 3065

HDU3743 Frosh Week 归并排序求逆序对的数量

题目链接:https://cn.vjudge.net/problem/HDU-3743  题意:         给出一组 n 个数,每次交换相邻的两个整数,要你用最少的交换次数使得该排列呈递增排列。输出需要交换的次数。 分析:         这道题和 POJ 2299 Ultra-QuickSort 一模一样,都可以采用归并排序的方法,在排序中计数即可。归并排序的具体实现可以点击这里查...

左云帆 296

AutoSAR系列讲解(深入篇)13.6-闪烁一颗LED灯 6

闪烁一颗LED灯:配置SWC和生成代码

雪云飞星的博客 1万+

HDU 3743 Frosh Week

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description During Frosh Week, students play various fun games to get to know each

ACResume的专栏 1453

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

hdu3743——Frosh Week

Problem Description During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are th

Alex 975

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

hdu 3743 Frosh Week(求逆序数方法总结)

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1785    Accepted Submission(s): 592 Problem Description During Frosh Wee

ACway的专栏 4360

HDU3743(Frosh Week)

Frosh Week Problem Description During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are then asked to arrange themselves according to so

weixin_43808717的博客 225

hdu3743Frosh Week

用树状数组求逆序对数,没说编号由1到n所以要将其编号离散化,否则总是数组越界啊,吃一堑长一智啊。。。区间修改,点查询是向下修改,向后求和。点修改,区间查询是向后修改,向前求和。 #include #include #include #include #include #define LL __int64 const int maxn = 1000111; using namespace std

I fight, so you don't have to 664

HDU 3743 Frosh Week 树状数组

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 999    Accepted Submission(s): 307 Problem Description During Frosh Week

sky_fighting的专栏 709

HDU 3743 Frosh Week 【归并排序模板题】

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2217    Accepted Submission(s): 700 Problem Description During Frosh Week

wyjwyl的专栏 800

UVA11858 LA8231 HDU3743 Frosh Week【逆序数】

During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are then asked to arrange t...

海岛Blog 556

HDU 3743 Frosh Week(树状数组或归并排序求逆序)

HDU 3743 Frosh Week(树状数组或归并排序求逆序) 分析: 首先这题类似于POJ2299: http://blog.csdn.net/u013480600/article/details/21277047 其实题目就是给你n个数的排列,然后问你这n个数的逆序和是多少.可以用归并排序做,也可以用树状数组左,其中用树状数组做的话,每读入一个a[i],当前树状数组中先查找已经出现

code 1379

HDU 3743 Frosh Week【树状数组 离散化】

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3675    Accepted Submission(s): 1269 Problem Description During Frosh Week,

Head_Hard的博客 304

【树状数组(逆序数)】hdu 3743 Frosh Week

http://acm.hdu.edu.cn/showproblem.php?pid=3743 分析:就是求逆序数,要注意离散化处理,题目信息也不说行清楚 #include #include #include #include using namespace std; const int NM=1000005; int a[NM],c[NM]; struct Node{ i

yduqytd的专栏 734

HDU 3743 Frosh Week (归并排序)

Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1919    Accepted Submission(s): 619 Problem Description During Frosh Wee

芝兰生于深谷,不以无人而不芳 1631

hdu 3743 Frosh Week (归并排序·逆序数)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=3743 Frosh Week Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2265    Accepted Submission(

theArcticOcean 805

HDU 3743 Frosh Week(逆序对-BIT)

Description 给出一个长度为n的序列,求序列逆序对 Input 第一行为序列长度n,之后n行每行一个整数表示该序列 Output 输出逆序对数 Sample Input 3 3 1 2 Sample Output 2 Solution 数据太大,所以要离散化后再用树状数组求逆序对即可 Code #include #include #include #i

ZSQ 725
上一篇: upper_bound()和low_bound函数的基本使用和理解(转)
下一篇: A + B for you again hdu 1867
admin__
博客等级 码龄8年 3粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值