목록슬라이딩 윈도우 (29)
넘치게 채우기

https://www.acmicpc.net/problem/28703BOJ - 28703 - Double It문제 유형: 정렬, 우선순위 큐, 슬라이딩 윈도우, 그리디문제 난이도: Gold III시간 제한: 1초메모리 제한: 1024MB 문제양의 정수로 이루어진 길이가 N$N$인 배열 A1,⋯,AN이 주어집니다. 당신은 원하는 만큼 다음 조작을 할 수 있습니다.배열에서 원하는 수 하나를 골라서 2를 곱합니다.조작 이후 A1,⋯,AN의 최댓값과 최솟값의 차이로 가능한 최솟값을 구하세요. 입력첫 줄에 배열의 길이 N이 주어집니다. (1≤N≤200000)둘째 줄에 N개의 양의 정수 A1,A2,⋯,AN이 주어집니다. (1≤Ai≤10^9) 출력조작 이후 A1,⋯,AN의 최댓값과 최솟값의 차이로 가능한 최솟값을 구하..
https://codeforces.com/contest/2064/problem/BCodeforces Round 1005(Div. 2) - B. Variety is Discouraged문제 유형: 그리디, 해 구성하기, 슬라이딩 윈도우시간 제한: 1.5초메모리 제한: 256MB 문제Define the score of an arbitrary array b">b to be the length of b">b minus the number of distinct elements in b">b. For example:The score of [1,2,2,4]">[1,2,2,4] is 1">1, as it has length 4">4 and only 3">3 distinct elements (1">1, 2">2, 4">..
https://leetcode.com/problems/product-of-the-last-k-numbers/description/Product of the Last K Numbers문제 유형: 부분합, 슬라이딩 윈도우문제 난이도: Medium 문제Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream.Implement the ProductOfNumbers class:ProductOfNumbers() Initializes the object with an empty stream.void add(int num) Appends the integer num t..
https://leetcode.com/problems/maximum-ascending-subarray-sum/description/leetcode - Maximum Ascending Subarray Sum문제 유형: 슬라이딩 윈도우문제 난이도: Easy 문제Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums.A subarray is defined as a contiguous sequence of numbers in an array.A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i wh..
https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/description/leetcode - Longest Strictly Increasing or Strictly Decreasing Subarray문제 유형: 슬라이딩 윈도우문제 난이도: Easy 문제You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing. 정수 배열 nums가 주어진다. 가장 긴 오름차순 또는 내림차순 부분배열의 길이를..
https://leetcode.com/problems/shifting-letters-ii/description/leetcode - Shifting Letters II문제 유형: 문자열 처리, 슬라이딩 윈도우, 라인 스위핑, 구간합문제 난이도: Medium 문제You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusive) forward if directioni = 1, or sh..
https://www.acmicpc.net/problem/1644BOJ - 소수의 연속합문제 유형: 수학, 정수론, 슬라이딩 윈도우문제 난이도: Gold III시간 제한: 2초메모리 제한: 128MB 문제하나 이상의 연속된 소수의 합으로 나타낼 수 있는 자연수들이 있다. 몇 가지 자연수의 예를 들어 보면 다음과 같다.3 : 3 (한 가지)41 : 2+3+5+7+11+13 = 11+13+17 = 41 (세 가지)53 : 5+7+11+13+17 = 53 (두 가지)하지만 연속된 소수의 합으로 나타낼 수 없는 자연수들도 있는데, 20이 그 예이다. 7+13을 계산하면 20이 되기는 하나 7과 13이 연속이 아니기에 적합한 표현이 아니다. 또한 한 소수는 반드시 한 번만 덧셈에 사용될 수 있기 때문에, 3+5+..
https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/description/leetcode - Maximum Sum of 3 Non-Overlapping Subarrays문제 유형: 슬라이딩 윈도우, 부분합, 다이나믹 프로그래밍문제 난이도: Hard 문제Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them.Return the result as a list of indices representing the starting position of each int..
https://www.acmicpc.net/problem/1806BOJ - 부분합문제 유형: 부분합, 투 포인터, 슬라이딩 윈도우문제 난이도: Gold IV시간 제한: 0.5초메모리 제한: 128MB 문제10,000 이하의 자연수로 이루어진 길이 N짜리 수열이 주어진다. 이 수열에서 연속된 수들의 부분합 중에 그 합이 S 이상이 되는 것 중, 가장 짧은 것의 길이를 구하는 프로그램을 작성하시오. 입력첫째 줄에 N (10 ≤ N 출력첫째 줄에 구하고자 하는 최소의 길이를 출력한다. 만일 그러한 합을 만드는 것이 불가능하다면 0을 출력하면 된다. 풀이슬라이딩 윈도우를 이용하면 된다.매번 right를 더해줄 때마다, left쪽에서 뺄 수 있는만큼 빼본다.right를 한칸 밀면, left쪽에서는 sum이상인동..
https://leetcode.com/problems/maximum-beauty-of-an-array-after-applying-operation/description/leetcode - Maximum Beauty of an Array After Applying Operation문제 유형: 정렬, 슬라이딩 윈도우문제 난이도: Medium 문제You are given a 0-indexed array nums and a non-negative integer k.In one operation, you can do the following:Choose an index i that hasn't been chosen before from the range [0, nums.length - 1].Replace nums..