목록전체 글 (1209)
넘치게 채우기
https://www.acmicpc.net/problem/7453BOJ - 합이 0인 네 정수문제 유형: 이진탐색, 해시, 투포인터, MITM(Meet-In-The-Middle)문제 난이도: Gold II시간 제한: 12초메모리 제한: 1024MB 문제정수로 이루어진 크기가 같은 배열 A, B, C, D가 있다.A[a], B[b], C[c], D[d]의 합이 0인 (a, b, c, d) 쌍의 개수를 구하는 프로그램을 작성하시오. 입력첫째 줄에 배열의 크기 n (1 ≤ n ≤ 4000)이 주어진다. 다음 n개 줄에는 A, B, C, D에 포함되는 정수가 공백으로 구분되어져서 주어진다. 배열에 들어있는 정수의 절댓값은 최대 2^28이다. 출력합이 0이 되는 쌍의 개수를 출력한다. 풀이브루트 포스는 n^4의 ..
https://leetcode.com/problems/bitwise-xor-of-all-pairings/description/leetcode - Bitwise XOR of All Pairings문제 유형: 비트마스킹문제 난이도: Medium 문제You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer ..
https://codeforces.com/contest/2055/problem/CCodeforces Round 996(Div.2) - C. The Trail문제 유형: 행렬, 수학, 구현, 생성형시간 제한: 2초메모리 제한: 256MB 문제In the wilderness lies a region of mountainous terrain represented as a rectangular grid with n">n rows and m">m columns. Each cell in the grid is identified by its position (i,j)">(i,j), where i">i is the row index and j">j is the column index. The altitude of ce..
https://www.acmicpc.net/problem/12015BOJ - 가장 긴 증가하는 부분 수열 2문제 유형: LIS(Longest Increasing Subsequence), 다이나믹 프로그래밍, 이진 탐색난이도: Gold II시간 제한: 1초메모리 제한: 512MB 문제수열 A가 주어졌을 때, 가장 긴 증가하는 부분 수열을 구하는 프로그램을 작성하시오.예를 들어, 수열 A = {10, 20, 10, 30, 20, 50} 인 경우에 가장 긴 증가하는 부분 수열은 A = {10, 20, 10, 30, 20, 50} 이고, 길이는 4이다. 입력첫째 줄에 수열 A의 크기 N (1 ≤ N ≤ 1,000,000)이 주어진다.둘째 줄에는 수열 A를 이루고 있는 Ai가 주어진다. (1 ≤ Ai ≤ 1,00..
https://leetcode.com/problems/minimize-xor/description/leetcode - Minimize XOR문제 유형: 비트마스킹, 그리디문제 난이도: Medium 문제Given two positive integers num1 and num2, find the positive integer x such that:x has the same number of set bits as num2, andThe value x XOR num1 is minimal.Note that XOR is the bitwise XOR operation.Return the integer x. The test cases are generated such that x is uniquely determine..
https://codeforces.com/contest/2055/problem/BCodeforces Round 996(Div.2) - B. Crafting문제 유형: 수학, 그리디시간 제한: 1초메모리 제한: 256MB 문제There are n">n different types of magical materials, numbered from 1">1 to n">n. Initially, you have ai">ai units of material i">i for each i">i from 1">1 to n">n. You are allowed to perform the following operation:Select a material i">i (where 1≤i≤n">1≤i≤n)...
https://codeforces.com/contest/2055/problem/ACodeforces Round 996(Div.2) - A. Two Frogs문제 유형: 구현, 수학, 그리디시간 제한: 1초메모리 제한: 256MB 문제There are n">n lilypads arranged in a row, numbered from 1">1 to n">n from left to right. Alice and Bob are frogs initially positioned on distinct lilypads, a">a and b">b, respectively. They take turns jumping, starting with Alice.During a frog's turn, it can jump eit..
https://www.acmicpc.net/problem/1202BOJ - 보석 도둑문제 유형: 우선순위 큐, 정렬, 그리디, 투포인터문제 난이도: Gold II시간 제한: 1초메모리 제한: 256MB 문제세계적인 도둑 상덕이는 보석점을 털기로 결심했다.상덕이가 털 보석점에는 보석이 총 N개 있다. 각 보석은 무게 Mi와 가격 Vi를 가지고 있다. 상덕이는 가방을 K개 가지고 있고, 각 가방에 담을 수 있는 최대 무게는 Ci이다. 가방에는 최대 한 개의 보석만 넣을 수 있다.상덕이가 훔칠 수 있는 보석의 최대 가격을 구하는 프로그램을 작성하시오. 입력첫째 줄에 N과 K가 주어진다. (1 ≤ N, K ≤ 300,000)다음 N개 줄에는 각 보석의 정보 Mi와 Vi가 주어진다. (0 ≤ Mi, Vi ≤ 1,..
https://leetcode.com/problems/find-the-prefix-common-array-of-two-arrays/description/leetcode - Find the Prefix Common Array of Two Arrays문제 유형: 구현, 카운팅, 구간합문제 난이도: Medium 문제You are given two 0-indexed integer permutations A and B of length n.A prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B.Re..
https://www.acmicpc.net/problem/2178BOJ - 미로 탐색문제 유형: 행렬, bfs문제 난이도: Silver I시간 제한: 1초메모리 제한: 192MB 문제N×M크기의 배열로 표현되는 미로가 있다.101111101010101011111011미로에서 1은 이동할 수 있는 칸을 나타내고, 0은 이동할 수 없는 칸을 나타낸다. 이러한 미로가 주어졌을 때, (1, 1)에서 출발하여 (N, M)의 위치로 이동할 때 지나야 하는 최소의 칸 수를 구하는 프로그램을 작성하시오. 한 칸에서 다른 칸으로 이동할 때, 서로 인접한 칸으로만 이동할 수 있다.위의 예에서는 15칸을 지나야 (N, M)의 위치로 이동할 수 있다. 칸을 셀 때에는 시작 위치와 도착 위치도 포함한다. 입력첫째 줄에 두 정수..