From 4f0f040222c1c5658afb95d76c735ff18014186e Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 25 Feb 2026 23:51:37 +0900 Subject: [PATCH] =?UTF-8?q?[Week08]=20BOJ=202531:=20=ED=9A=8C=EC=A0=84?= =?UTF-8?q?=EC=B4=88=EB=B0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sukangpunch.java" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "weekly/week08/BOJ_2531_\355\232\214\354\240\204\354\264\210\353\260\245/sukangpunch.java" diff --git "a/weekly/week08/BOJ_2531_\355\232\214\354\240\204\354\264\210\353\260\245/sukangpunch.java" "b/weekly/week08/BOJ_2531_\355\232\214\354\240\204\354\264\210\353\260\245/sukangpunch.java" new file mode 100644 index 0000000..652cd82 --- /dev/null +++ "b/weekly/week08/BOJ_2531_\355\232\214\354\240\204\354\264\210\353\260\245/sukangpunch.java" @@ -0,0 +1,75 @@ +package it_company_work_book.silver; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +// 회전초밥 +// 투포인터, 브루트포스, 슬라이딩 윈도우 +/** + * 현 윈도우 상태에 맞게 현재 먹은 스시 개수 및 중복을 처리할 sushiCounts 배열을 두고, + * 중복과 쿠폰을 고려해서 겹치지 않는 스시 개수를 구할 uniqueCount 을 둔다. + * 초기 슬라이딩 윈도우 값을 구한 다음, 해당 값에서 인덱스를 1씩 이동해가며 윈도우의 처음 인덱스 값을 윈도우의 다음 인덱스를 추가한다. + * 원형 배열이기 때문에 %연산을 통해서 범위를 지정한다. + */ +public class BOJ_2531 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String []s = br.readLine().split(" "); + int N = Integer.parseInt(s[0]); + int d = Integer.parseInt(s[1]); + int k = Integer.parseInt(s[2]); + int c = Integer.parseInt(s[3]); + + int [] dishes = new int[N]; + + for(int i=0; i