https://www.acmicpc.net/problem/15565코드import sysinput = sys.stdin.readlinen, k = map(int, input().split())dolls = list(map(int, input().split()))l = 0answer = n+1lion = 0for r in range(n): if dolls[r] == 1: lion += 1 while lion >= k: if lion == k and dolls[l] == 1: break if dolls[l] == 1: lion -= 1 l += 1 if lion == k: answer = m..
문제풀이/투포인터
https://www.acmicpc.net/problem/15831코드n, b, w = map(int, input().split())pebbles = input()answer = 0left, right = 0, 0count = dict([("B", 0), ("W", 0)])count[pebbles[left]] += 1while right = w: answer = max(answer, right-left+1) right += 1 if right > n-1: break count[pebbles[right]] += 1 while count['B'] > b: count[pebbles[left]] -= 1 left += 1print(answe..
https://www.acmicpc.net/problem/1253코드import sysinput = sys.stdin.readlinen = int(input())arr = list(map(int, input().split()))arr.sort()ans = 0for i in range(n): l, r = 0, n-1 while l = r: break if arr[l]+arr[r] == arr[i]: ans += 1 break elif arr[l]+arr[r] 설명1. 처음 입력으로 주어진 배열 arr를 오름차순 정렬한다.2. 정렬된 arr의 첫번째 원소부터 좋은 수인지 판별한다. a. 투포인터로 검색을 할..
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AY6cg0MKeVkDFAXt&categoryId=AY6cg0MKeVkDFAXt&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1 코드for tc in range(1, int(input())+1): n, k = map(int, input().split()) candy = list(map(int, input().split())) candy.sort() ans = int(1e9) for i in r..
11687번: 팩토리얼 0의 개수 첫째 줄에 M (1 ≤ M ≤ 100,000,000)이 주어진다. www.acmicpc.net 코드 m = int(input()) def count_zero(n): # 왼쪽 끝 0 개수 구하기 res = 0 while n >= 5: res += n//5 n //= 5 return res s, e = 0, int(1e9) ans = -1 while s