25.03.20 코딩테스트 대비
·
알고리즘/코딩테스트 대비
BOJ 11660. 구간 합 구하기 5https://www.acmicpc.net/problem/11660  내 코드import sysinput = sys.stdin.readlinen, m = map(int, input().split())board = [list(map(int, input().split())) for _ in range(n)]for i in range(n): for j in range(n): if i == 0 and j == 0: continue elif j == 0: board[i][j] += board[i-1][-1] else: board[i][j] += board[i][j-1]for ..
[LeetCode] 3108. Minimum Cost Walk in Weighted Graph (Python)
·
알고리즘/LeetCode
난이도: HardProblem DescriptionThere is an undirected weighted graph with n vertices labeled from 0 to n - 1. You are given the integer n and an array edges, where edges[i] = [ui, vi, wi] indicates that there is an edge between vertices ui and vi with a weight of wi. A walk on a graph is a sequence of vertices and edges. The walk starts and ends with a vertex, and each edge connects the vertex that..
25.03.19 코딩테스트 대비
·
알고리즘/코딩테스트 대비
BOJ 15686. 치킨 배달https://www.acmicpc.net/problem/15686  내 코드import sysinput = sys.stdin.readlinen, m = map(int, input().split())city = []houses = []chicken = []for i in range(n): city.append(list(map(int, input().split()))) for j in range(n): if city[i][j] == 1: houses.append((i, j)) elif city[i][j] == 2: chicken.append((i, j))answer = float('inf')def bac..
25.03.18 코딩테스트 대비
·
알고리즘/코딩테스트 대비
BOJ 2096. 내려가기 2096번: 내려가기N줄에 0 이상 9 이하의 숫자가 세 개씩 적혀 있다. 내려가기 게임을 하고 있는데, 이 게임은 첫 줄에서 시작해서 마지막 줄에서 끝나게 되는 놀이이다.먼저 처음에 적혀 있는 세 개의 숫자 중에서www.acmicpc.net   내 코드import sysinput = sys.stdin.readlinen = int(input())dp1 = [0, 0, 0]dp2 = [0, 0, 0]for _ in range(n): nums = (list(map(int, input().split()))) dp1[0], dp1[1], dp1[2] = min(dp1[0], dp1[1]) + nums[0], min(dp1) + nums[1], min(dp1[1], dp1[2..
[LeetCode] 2401. Longest Nice Subarray (Python)
·
알고리즘/LeetCode
난이도: MediumProblem DescriptionYou are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0. Return the length of the longest nice subarray. A subarray is a contiguous part of an array. Note that subarrays of length 1 are always considered nice.  Problem Examp..
[LeetCode] 2206. Divide Array Into Equal Pairs (Python)
·
알고리즘/LeetCode
난이도: EasyProblem DescriptionYou are given an integer array nums consisting of 2 * n integers.You need to divide nums into n pairs such that:Each element belongs to exactly one pair.The elements present in a pair are equal.Return true if nums can be divided into n pairs, otherwise return false. Problem ExampleExample 1:Input: nums = [3,2,3,2,2,2]Output: trueExplanation: There are 6 elements in nu..