-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Silver III] Title: 눈사람, Time: 148 ms, Memory: 56064 KB -BaekjoonHub
- Loading branch information
1 parent
2366f4e
commit 023d6bd
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# [Silver III] 눈사람 - 32201 | ||
|
||
[문제 링크](https://www.acmicpc.net/problem/32201) | ||
|
||
### 성능 요약 | ||
|
||
메모리: 56064 KB, 시간: 148 ms | ||
|
||
### 분류 | ||
|
||
자료 구조, 해시를 사용한 집합과 맵, 정렬 | ||
|
||
### 제출 일자 | ||
|
||
2024년 9월 17일 00:22:20 | ||
|
||
### 문제 설명 | ||
|
||
<p>평창 동계 올림픽의 하이라이트를 장식할 눈사람 만들기 경기가 시작되었다! 이 경기에서는 주어진 시간동안 눈사람을 크게 만드는 사람이 우승한다.</p> | ||
|
||
<p>애리가 중계 방송을 켰을 때, 경기가 시작한지 얼마 되지 않은 시점이었다. 중계 방송에서는 순위표를 방송하고 있었다. 순위표는 등수 순서대로 각 선수의 등번호를 나열한 표이다. 애리는 순위표에 나온 등번호를 순서대로 기억해 두었다.</p> | ||
|
||
<p>애리가 잠시 딴짓을 하고 오자, 경기가 끝났다. 경기가 끝난 시점의 순위표가 주어젔을 때, 애리가 기억하는 시점에서의 등수와 비교해 가장 등수가 많이 상승한 선수들의 등번호를 구하여라.</p> | ||
|
||
### 입력 | ||
|
||
<p>첫째 줄에는 경기에 참가한 선수의 수 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>이 주어진다.</p> | ||
|
||
<p>둘째 줄에는 애리가 중계 방송을 켠 시점에서 각 선수의 등번호를 나타내는 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>개의 정수 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-msub><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D434 TEX-I"></mjx-c></mjx-mi><mjx-script style="vertical-align: -0.15em;"><mjx-mn class="mjx-n" size="s"><mjx-c class="mjx-c31"></mjx-c></mjx-mn></mjx-script></mjx-msub><mjx-mo class="mjx-n"><mjx-c class="mjx-c2C"></mjx-c></mjx-mo><mjx-mo class="mjx-n" space="2"><mjx-c class="mjx-c22EF"></mjx-c></mjx-mo><mjx-mo class="mjx-n" space="2"><mjx-c class="mjx-c2C"></mjx-c></mjx-mo><mjx-msub space="2"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D434 TEX-I"></mjx-c></mjx-mi><mjx-script style="vertical-align: -0.15em;"><mjx-mi class="mjx-i" size="s"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-script></mjx-msub></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>A</mi><mn>1</mn></msub><mo>,</mo><mo>⋯</mo><mo>,</mo><msub><mi>A</mi><mi>N</mi></msub></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$A_1, \cdots, A_N$</span></mjx-container>가 등수 순서대로 공백을 사이에 두고 주어진다.</p> | ||
|
||
<p>셋째 줄에는 경기가 끝난 시점에서 각 선수의 등번호를 나타내는 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>개의 정수 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-msub><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D435 TEX-I"></mjx-c></mjx-mi><mjx-script style="vertical-align: -0.15em;"><mjx-mn class="mjx-n" size="s"><mjx-c class="mjx-c31"></mjx-c></mjx-mn></mjx-script></mjx-msub><mjx-mo class="mjx-n"><mjx-c class="mjx-c2C"></mjx-c></mjx-mo><mjx-mo class="mjx-n" space="2"><mjx-c class="mjx-c22EF"></mjx-c></mjx-mo><mjx-mo class="mjx-n" space="2"><mjx-c class="mjx-c2C"></mjx-c></mjx-mo><mjx-msub space="2"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D435 TEX-I"></mjx-c></mjx-mi><mjx-script style="vertical-align: -0.15em;"><mjx-mi class="mjx-i" size="s"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-script></mjx-msub></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>B</mi><mn>1</mn></msub><mo>,</mo><mo>⋯</mo><mo>,</mo><msub><mi>B</mi><mi>N</mi></msub></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$B_1, \cdots, B_N$</span></mjx-container>가 등수 순서대로 공백을 사이에 두고 주어진다.</p> | ||
|
||
### 출력 | ||
|
||
<p>가장 순위가 많이 상승한 선수들의 등번호들을 경기가 끝난 시점의 등수 순서대로 공백을 사이에 두고 출력한다.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
[시도2] | ||
dict 만들어서 서치 시간 줄이기 O(1) | ||
[시도1] 시간초과 | ||
- (시간초과 예상) N^2 = 10^10 | ||
- 그렇다고 table을 만들기에는 10^9 배열 크기 만들어도 될까? | ||
""" | ||
|
||
import sys | ||
readline = lambda: sys.stdin.readline().strip() | ||
|
||
# 전처리 | ||
N = int(readline()) | ||
before_arr = list(map(int, readline().split())) | ||
after_arr = list(map(int, readline().split())) | ||
after_rank_dict = {} | ||
|
||
for rank in range(N): | ||
a_member = after_arr[rank] | ||
after_rank_dict[a_member] = rank | ||
|
||
max_level_up = 0 | ||
people = [] | ||
|
||
for before_rank in range(N): | ||
member = before_arr[before_rank] | ||
after_rank = after_rank_dict[member] | ||
|
||
level_up = before_rank - after_rank | ||
if level_up > max_level_up: | ||
max_level_up = level_up | ||
people = [member] | ||
elif level_up == max_level_up: | ||
people.append(member) | ||
|
||
|
||
print(" ".join(list(map(str, people)))) |