1696. 困牛排序
摘要
Title: 1696. 困牛排序
Tag: 思维
Memory Limit: 64 MB
Time Limit: 1000 ms
Powered by:NEFU AB-IN
1696. 困牛排序
-
题意
-
思路
从后往前找到第一个a[i] > a[i + 1]的元素,答案就为i + 1(下标从0开始),构造方法为插入排序
-
代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15'''
Author: NEFU AB-IN
Date: 2022-02-10 15:18:39
FilePath: \ACM\Acwing\1696.py
LastEditTime: 2022-02-10 15:22:25
'''
if __name__ == "__main__":
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(n - 2, -1, -1):
if a[i] > a[i + 1]:
res = i + 1
break
print(res)