2019 GDUT Rating Contest III : Problem A. Out of Sorts
题面:
A. Out of Sorts
题目描述:
题目分析:




1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 #include <cmath>
5 #include <set>
6 #include <algorithm>
7 using namespace std;
8 const int maxn = 1e6+5;
9 int n;
10 struct node{
11 long long a; //要进行排序的元素
12 long long p; //下标
13 };
14 node A[maxn];
15
16 bool cmp(node x, node y){ //比较函数
17 return x.a < y.a; //从小到大排序
18 }
19
20 int main(){
21 scanf("%d", &n);
22
23 for(int i = 0; i < n; i++){
24 scanf("%lld", &A[i].a);
25 A[i].p = i;
26 }
27
28 stable_sort(A, A+n, cmp); //排序
29
30 int moo = 0; //初始化最大值
31 for(int i = 0; i < n; i++){
32 //往前面移动过的数就是之前没排序前的下标大于排序后的下标
33 //这里可以与求最大值结合在一起判断
34 if(A[i].p-i > moo){ //A[i]-i就是移动的步数
35 moo = A[i].p-i;
36 }
37 }
38
39 printf("%d\n", moo+1); //记得要+1
40 return 0;
41 }
2019 GDUT Rating Contest III : Problem A. Out of Sorts的更多相关文章
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest II : Problem F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest I : Problem A. The Bucket List
题面: A. The Bucket List Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- .NET Core项目自动化测试和代码覆盖率审查
这篇文章给大家分享一下,如何配置.NET Core项目自动化测试和代码覆盖率审查. 基本知识,请参考这里: https://docs.microsoft.com/en-us/dotnet/core/t ...
- POJ 2288 Islands and Bridges(状压DP)题解
题意:n个点,m有向边,w[i]表示i的价值,求价值最大的哈密顿图(只经过所有点一次).价值为:所有点的w之和,加上,每条边的价值 = w[i] * w[j],加上,如果连续的三个点相互连接的价值 = ...
- 记一次 lampiao渗透(Drupal+脏牛提权)
vulnhub|渗透测试lampiao 题记 最近在打靶机,发现了一个挺有意思的靶机,这里想跟大家分享一下. 环境准备 vulnhub最近出的一台靶机 靶机(https://www.vulnhub.c ...
- 如何快速定位 Redis 热 key?
背景 在 Redis 中,热 key 指的是那些在一段时间内访问频次比较高的键值,具体到业务上,商品的限时抢购.瞬时的新闻热点或某个全局性的资源,都极有可能产生热点 key. 热点 key 的出现可能 ...
- sentry.event & UnhandledRejection & promise rejection
sentry.event & UnhandledRejection & promise rejection Non-Error promise rejection captured s ...
- how to write string to file in bash
how to write string to file in bash https://stackoverflow.com/questions/22713667/shell-script-how-to ...
- js assert
js assert console.assert The console.assert() method writes an error message to the console if the a ...
- NGK.IO网络安全大会暨区块链安全与应用创新论坛圆满落幕
近日,NGK.IO网络安全大会暨区块链安全与应用创新论坛于美国McCormick Place国际会议中心圆满落幕. 论坛围绕"进化繁荣发展·安全链接未来"这一主题,由NGK.IO硅 ...
- Mysql的join算法
本文转载自Mysql的join算法 导语 在Mysql中,使用Nested-Loop Join的算法思想去优化join,Nested-Loop Join翻译成中文则是"嵌套循环连接" ...
- C# 类中操作主窗体控件
主窗体程序: using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...