백준

백준 1377번: 버블 소트

2호0 2023. 2. 4. 20:25

https://www.acmicpc.net/problem/1377

 

1377번: 버블 소트

첫째 줄에 N이 주어진다. N은 500,000보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에 A[1]부터 A[N]까지 하나씩 주어진다. A에 들어있는 수는 1,000,000보다 작거나 같은 자연수 또는 0이다.

www.acmicpc.net

1
2
3
4
5
6
7
8
9
10
11
12
13
= int(input())
= []
 
for i in range(n):
    a.append((int(input()), i))
    
= sorted(a)
max = 0
 
for i in range(n):
    if max < s[i][1]-i:
        max = s[i][1]-i
print(max+1)
cs