HDU 5122 K.Bro Sorting(2014北京区域赛现场赛K题 模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5122
解题报告:定义一种排序算法,每一轮可以随机找一个数,把这个数与后面的比这个数小的交换,一直往后判断,直到后面没有比这个数小的,这样称为一轮,现在给定一个长度为n的序列,要你求,至少要经过多少轮,可以使这个序列成为有序的。
由于只能跟后面的数进行比较,所以我只要统计后面的数有比这个数小的数的个数就可以了。从后往前扫一遍,每次更新当前最小的。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef __int64 INT;
const int maxn = 1e6+; int A[maxn]; int main()
{
int T,n,kase = ;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = ;i < n;++i)
scanf("%d",&A[i]);
INT ans = ;
int M = 0x7fffffff;
for(int i = n-;i >= ;--i)
{
if(M < A[i]) ans++;
M = min(M,A[i]);
}
printf("Case #%d: %I64d\n",kase++,ans);
}
return ;
}
HDU 5122 K.Bro Sorting(2014北京区域赛现场赛K题 模拟)的更多相关文章
- HDU 5122 K.Bro Sorting(模拟——思维题详解)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5122 Problem Description Matt's friend K.Bro is an A ...
- HDU 5122 K.Bro Sorting
K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Tot ...
- 基础题:HDU 5122 K.Bro Sorting
Matt's friend K.Bro is an ACMer.Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubble sort will ...
- hdoj 5122 K.Bro Sorting 贪心
K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Tot ...
- 树状数组--K.Bro Sorting
题目网址: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110064#problem/D Description Matt’s frie ...
- K.Bro Sorting
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submissio ...
- K - K.Bro Sorting
Description Matt’s friend K.Bro is an ACMer. Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubb ...
- K.Bro Sorting(思维题)
K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)T ...
- HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题
第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...
随机推荐
- JAVA 自定义状态码
返回信息类(ResponseInfo): public class ResponseInfo { public static final String Status = "status&qu ...
- BZOJ3678: wangxz与OJ
splay缩点. #include<bits/stdc++.h> #define L(t) (t)->c[0] #define R(t) (t)->c[1] #define F ...
- StringUtils 的常用方法
StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 ...
- myeclipse 破解步骤
Fllow Orders.0. Close MyEclipse Application(if you wanna replace jar file).1. Fill usercode2. Fill s ...
- C#------DateTime自定义格式
var text = Convert.ToString(DateTime.Now.ToString("yyyy/MM/dd"));
- JavaWeb学习笔记——开发动态WEB资源(二)HelloWord
该工程的功能是在页面上输出一段话 首先在src里面新建一个class,在interface里面添加javax.servlet.Servlet 以下是HelloServlet.java中的代码: pac ...
- ecshop 团购-》调取评论
涉及到的文件及代码:lib_insert.php,comments.lbi,{insert name='comments' type=$type id=$id} html代码: <blockqu ...
- 深刻认识一下session
session是什么: session即会话,是一种持续性,双向的连接. session和cookie在本质上没什么区别,都是针对http协议的局限性提出的一种保持客户端和服务端会话状态的机制. se ...
- LINQ的左连接、右连接、内连接
.左连接: var LeftJoin = from emp in ListOfEmployees join dept in ListOfDepartment on emp.DeptID equals ...
- Helixoft VSdocman 是一个集成于Visual Studio并提供了命令行版本的帮助文档编译工具
http://www.helixoft.com/vsdocman/overview.html https://blog.fishlee.net/2016/01/14/helixoft-vsdocman ...