From 6ad7a91defff484f79bff7da653baf8a6b9e07c3 Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 18 Dec 2025 23:48:36 +0900 Subject: [PATCH] =?UTF-8?q?[20251218]=20BOJ=20/=20P5=20/=20Lights=20/=20?= =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- khj20006/202512/18 BOJ P5 Lights.md | 85 +++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 khj20006/202512/18 BOJ P5 Lights.md diff --git a/khj20006/202512/18 BOJ P5 Lights.md b/khj20006/202512/18 BOJ P5 Lights.md new file mode 100644 index 00000000..2912404c --- /dev/null +++ b/khj20006/202512/18 BOJ P5 Lights.md @@ -0,0 +1,85 @@ +```java +import java.sql.Array; +import java.util.*; +import java.io.*; + +public class Main { + + static BufferedReader br; + static BufferedWriter bw; + static StringTokenizer st; + + static int N, M; + static long[] toggle; + static List results; + static List leftResults; + static Map rightResults; + + public static void main(String[] args) throws Exception { + + input(); + solve(); + + } + + public static void input() throws Exception { + br = new BufferedReader(new InputStreamReader(System.in)); + + st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + toggle = new long[N]; + for(int i=0;i(); + bck(0, N/2, 0, 0); + leftResults = new ArrayList<>(); + leftResults.addAll(results); + + results = new ArrayList<>(); + bck(N/2, N, 0, 0); + rightResults = new TreeMap<>(); + for(long[] info : results) { + long status = info[0]; + int cnt = (int)info[1]; + if(!rightResults.containsKey(status) || rightResults.get(status) > cnt) rightResults.put(status, cnt); + } + + long ans = N; + for(long[] info : leftResults) { + long leftStatus = info[0]; + int cntLeft = (int)info[1]; + long target = ((1L<