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<