본문 바로가기

전체 글

[Python][백준 1379,1374][우선순위 큐,정렬] 강의실, 강의실 2 - 컴도리돌이 1374번: 강의실 첫째 줄에 강의의 개수 N(1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에 걸쳐 각 줄마다 세 개의 정수가 주어지는데, 순서대로 강의 번호, 강의 시작 시간, 강의 종료 시간을 의미한다. 강의 www.acmicpc.net 1379번: 강의실 2 첫째 줄에 강의의 개수 N(1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에 걸쳐 각 줄마다 세 개의 정수가 주어지는데, 순서대로 강의 번호, 강의 시작 시간, 강의 종료 시간을 의미한다. 강의 www.acmicpc.net 풀이 과정 - 강의실 1. 강의실을 최소로 배정하는 개수를 구해야 한다. 2. heap에서 시작시간, 끝나는 시간, 강의실 번호를 heap push를 한다. 3. 첫 번째로 시작시간이 가.. 더보기
[Python][백준 17836][BFS] 공주님을 구해라! - 컴도리돌이 17836번: 공주님을 구해라! 용사는 마왕이 숨겨놓은 공주님을 구하기 위해 (N, M) 크기의 성 입구 (1,1)으로 들어왔다. 마왕은 용사가 공주를 찾지 못하도록 성의 여러 군데 마법 벽을 세워놓았다. 용사는 현재의 가지고 있는 www.acmicpc.net 풀이 과정 1. bfs로 해결을 하였다. q에는 x, y 좌표 값과 이동 시간, 무기를 갖고 있는지 확인용 key 값을 1x4 배열로 넣어줬다. 2. 주의할 점은 방문 표시를 n x m 행렬로 해주면 안 된다. n x m으로 방문 표시를 하면 용사가 무기를 가질 때, 용사가 무기가 없어서 우회했던 경로를 다시 방문할 수 없기 때문에 시간 초과가 발생할 것이다. 3. q에서 pop을 할 때 x, y 값이 공주가 있는 곳(n-1, m-1)으로 올 경우.. 더보기
[Softeer][python] 지도 자동 구축 - 컴도리돌이 Softeer 연습문제를 담을 Set을 선택해주세요. 취소 확인 softeer.ai 풀이 과정 1. 규칙성을 찾는다. 4 - > 9 - > 25 -> 81 4 -> ((2 * √4) -1)^2 -> ((2 * √9) -1)^2 -> .... 풀이 코드 start = 4 for _ in range(int(input())) : start = int(((start ** (0.5)) * 2 - 1 ) ** 2) print(start) 더보기
[Python][백준 23843][우선순위 큐,정렬] 콘센트 - 컴도리돌이 23843번: 콘센트 광재는 전자기기 대여사업을 시작했다. 퇴근하기 전에 다음날 손님들에게 빌려줄 N개의 전자기기를 충전하려 한다. 사용 가능한 콘센트는 M개가 있고, 성능은 모두 동일하다. 전자기기들은 한 www.acmicpc.net 풀이 과정 1. 입력받은 충전 시간 배열을 내림차순 정렬을 시킨다. 2. 콘센트 배열을 생성시킨다. 3. 내림차순 정렬된 충전 시간을 콘센트 배열에 삽입한다. 3-1 ) 만약 콘센트 배열의 크기가 주어진 콘센트 개수(m) 보다 작을 경우 -> 콘센트 배열에 해당 time을 삽입 3-2 ) 만약 콘센트 배열의 크기가 주어진 콘센트 개수(m) 이상일 경우 -> 가장 작은 값 + 현재 time을 더해서 다시 삽입 4. 콘센트 배열에 있는 값 중 가장 큰 값을 출력한다. -> 가.. 더보기
[HackerRank][SQL][JOIN] Basic Join, Top Competitors - 컴도리돌이 Top Competitors | HackerRank Query a list of top-scoring hackers. www.hackerrank.com Problem Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which t.. 더보기
[HackerRank][SQL][JOIN] The Report - 컴도리돌이 The Report | HackerRank Write a query to generate a report containing three columns: Name, Grade and Mark. www.hackerrank.com Problem Ketty gives Eve a task to generate a report containing three columns: Name, Grade and Mark. Ketty doesn't want the NAMES of those students who received a grade lower than 8. The report must be in descending order by grade -- i.e. higher grades are entered first. I.. 더보기
[HackerRank][SQL][JOIN] Average Population of Each Continent - 컴도리돌이 Average Population of Each Continent | HackerRank Query the names of all continents and their respective city populations, rounded down to the nearest integer. www.hackerrank.com Problem Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer. Note: CITY.Countr.. 더보기
[HackerRank][SQL][JOIN] African Cities- 컴도리돌이 African Cities | HackerRank Query the names of all cities on the continent 'Africa'. www.hackerrank.com Problem Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'. Note: CITY.CountryCode and COUNTRY.Code are matching key columns. -> 아프리카 대륙에 있는 모든 도시의 이름을 출력하시오. Answer select a.name from city a inner join country b on a.countrycode = b.code where b.c.. 더보기

728x90