From de0cd3688ada137a716f79a29c9c2019b0bf49bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=80=ED=98=84=EC=84=9C?= <113419425+3veryDay@users.noreply.github.com> Date: Wed, 14 Jan 2026 18:37:46 +0900 Subject: [PATCH] =?UTF-8?q?260114=20:=20[BOJ=2031963]=20=EB=91=90=20?= =?UTF-8?q?=EB=B0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _hyunseo/31963.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 _hyunseo/31963.py diff --git a/_hyunseo/31963.py b/_hyunseo/31963.py new file mode 100644 index 00000000..279a469b --- /dev/null +++ b/_hyunseo/31963.py @@ -0,0 +1,35 @@ + +import sys, math +input = sys.stdin.readline + +N = int(input()) +arr = list(map(int, input().split())) + + +answer = 0 +current_k = 0 + + +for i in range(N-1) : + prev = arr[i] + curr = arr[i + 1 ] + + if prev > curr : + count = 0 + while curr < prev : + curr *= 2 + count += 1 + current_k += count + + if past <= arr[n+1] : + past = arr[n+1] + continue + else : + count = 0 + + while prev * 2 <= curr : + prev *= 2 + count += 1 + current_k = max(0, current_k - count) + answer += current_k +print(answer)