Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- nGrinder
- jvm ๋ฐ๋ฐ๋ฅ๊น์ง ํํค์น๊ธฐ
- docker
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- docker ps -a
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- JPA
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
- Kafka
- Entity
- s3 log ์ ์ฅ
- docker compose
- Codedeploy ์ค๋ฅ
- ์คํํ๋ ๋ฏธ์ค
- redis ํ ์คํธ์ฝ๋
- private subnet ec2 ๋ก์ปฌ ์ ์
- ๋ค์ค ์ปจํ ์ด๋
- ํ์ดํผ๋ฐ์ด์
- ์๋ฐ
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- redis ์กฐํ
- prod docker-compose
- ํ๋ก๊ทธ๋๋จธ์ค
- docker-compose kafka
- AWS Certified Solutions Architect - Associate
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- aws ์ฟ ํฐ
- aws saa ํฉ๊ฒฉ
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
Archives
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Python] ๋ฐฑ์ค 1966 & ํ๋ก๊ทธ๋๋จธ์ค ๊ธฐ๋ฅ๊ฐ๋ฐ ๋ณธ๋ฌธ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป/[๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
[Python] ๋ฐฑ์ค 1966 & ํ๋ก๊ทธ๋๋จธ์ค ๊ธฐ๋ฅ๊ฐ๋ฐ
๐คRyusun๐ค 2023. 6. 3. 21:35#๋ฐฑ์ค 1966 ํ๋ฆฐํฐ ํ
#์ค์๋๊ฐ ๋์ผ๋ฉด ์ถ๋ ฅ, ์๋๋ฉด ๋ค๋ก๋ณด๋ด๊ธฐ
#๋ช๋ฒ์งธ๋ก ์ถ๋ ฅํ๋์ง๊ฐ ์ ๋ต.
#์ฆ ์ค์๋๊ฐ ๋์ผ๋ฉด pop์ผ๋ก ์ถ๋ ฅํํ cnt+1
#์๋๋ฉด ๋ค๋ก ๋ณด๋ด๊ธฐ
import queue
def printer(queue):
cnt = 0
while True:
if queue[0][0] == max(queue, key=lambda x:x[0])[0]:
cnt+= 1
if queue[0][1] == m:
return cnt
else:
queue.pop(0) #์ค์๋ ๋์ ์์๋๋ก ํ๋ฆฐํธํด์ฃผ๊ธฐ๋๊น pop์ฌ์ฉ
else:
queue.append(queue.pop(0))
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
queue = list(map(int, input().split()))
queue = [(imprt, i) for i, imprt in enumerate(queue)]
#queue[0] = (imprt, i), queue[0][0] = imprt
print(printer(queue))
# ํ๋ก๊ทธ๋๋จธ์ค ๊ธฐ๋ฅ๊ฐ๋ฐ
import queue
progresses = input()
speeds = input()
def solution(progresses, speeds):
answer = []
while progresses:
for i in range(len((progresses))):
progresses[i] += speeds[i]
cnt = 0
while progresses and progresses[0] >= 100:
progresses.pop(0)
speeds.pop(0)
cnt += 1
if cnt > 0: answer.append(cnt)
return answer
solution(progresses, speeds)
๐Points
- enumerate() ํจ์
- ์ธ๋ฑ์ค(index)์ ์์๋ฅผ ๋์์ ์ ๊ทผํ๋ฉด์ ๋ฃจํenumerate()๋ฅผ ๋๋ฆฐ๋ค.
- ํจ์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ธ๋ฑ์ค์ ์์๋ก ์ด๋ฃจ์ด์ง ํํ(tuple)์ ๋ง๋ ๋ค.
- ๋ฐ๋ผ์ ์ธ๋ฑ์ค์ ์์๋ฅผ ๊ฐ๊ฐ ๋ค๋ฅธ ๋ณ์์ ํ ๋นํ๊ณ ์ถ๋ค๋ฉด ์ธ์ ํ๊ธฐ(unpacking)ํด์ฃผ๊ธฐ
ex) [(x, y) for y ,x in enumerate(list)]
- queue
- ์ด๋ ์์ ์์ ํ์ด์ผํ๋ ํญ๋ชฉ์ ๋ชจ๋ ๋ชจ์์ ์ฒ๋ฆฌํด์ผํ๋ค๋ฉด ํ๋ฅผ ์ฌ์ฉ
- ๋ฌธ์ ์์ ์ฒ๋ฆฌํด์ผํ ๋ฐ์ดํฐ๊ฐ ํ๋ฒ์ ์ฌ๋ฌ๊ฐ ์๊ธฐ๊ฑฐ๋, ๋ฐ๋ณต์ ์ผ๋ก ํน์ ์์ ์ ์ํํด์ผ ํ๋ ๊ตฌ์กฐ์ผ๋ ํ๋ฅผ ์ฌ์ฉํ์
- ๋ค์์ ์ฒ๋ฆฌํ ๋ชฉํ๋ฅผ ์์๋ ์ผ๋ก์จ ์ ๊ทผํ๊ธฐ ํธํ๊ฒ ํ๋ค.
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > [๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๋ฐฑ์ค 1302 & ๋ฐฑ์ค 1543 (0) | 2023.06.05 |
---|---|
[Python] ๋ฐฑ์ค 18352 (0) | 2023.06.04 |
[Python] ๋ฐฑ์ค 7576 & ๋ฐฑ์ค 14502 (0) | 2023.06.02 |
[Python] ๋ฐฑ์ค 2206 & ๋ฐฑ์ค 1697 (0) | 2023.06.01 |
[Python] ๋ฐฑ์ค 2606 & ๋ฐฑ์ค 1201 (0) | 2023.05.28 |