====== 수열 ====== ===== 풀이 ===== * [[ps:투 포인터#슬라이딩 윈도우]] 기법의 가장 기본적인 형태. 시간복잡도는 O(N) ===== 코드 ===== """Solution code for "BOJ 2559. 수열". - Problem link: https://www.acmicpc.net/problem/2559 - Solution link: http://www.teferi.net/ps/problems/boj/2559 Tags: [Sliding window] """ def main(): N, K = [int(x) for x in input().split()] # pylint: disable=unused-variable nums = [int(x) for x in input().split()] answer = s = sum(nums[:K]) for l, r in zip(nums, nums[K:]): s += r - l answer = max(answer, s) print(answer) if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:실버_4}}