728x90

www.acmicpc.net/problem/1059

 

1059번: 좋은 구간

[9, 10], [9, 11], [9, 12], [10, 11], [10, 12]

www.acmicpc.net

s = int(input())
l = list(map(int, input().split()))
n = int(input())

l.sort()
mn, mx = 0, 0
for i in l:
    if i < n:
        mn = i
    if i == n:
        result = 0
        break
    if n < i and mn != 0:
        mx = i
        break
        
print(mn, mx)

if mn == 0 and mx == 0:
    if max(l) < n:
        result = max(l)-n
    if min(l) > n:
        result = min(l)-n
else:
    result = 0
    for i in range(mn+1, n+1):
        for j in range(n, mx):
            # print(i,j)
            result += 1
        
if result == 0:
    print(result)
else:
    print(result-1)
반응형

'전.py' 카테고리의 다른 글

[python] 백준 1051 숫자 정사각형  (0) 2022.01.06
2021_10_18_월.txt  (0) 2021.10.18
[python] 백준 1145 적어도 대부분의 배수  (0) 2021.03.05
백준 2010 플러그  (0) 2021.01.27
백준 2748 피보나치 수 2  (0) 2021.01.23
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기