Skip to content

Commit f094a45

Browse files
committed
2026년 04월 27일 11:59:09
1 parent a73a84b commit f094a45

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# [4014] 쓰레기 소각장
2+
### 채점 결과
3+
Accepted
4+
### 제출 일자
5+
2026년 04월 27일 11:59:09
6+
### 성능 요약[추후 구현 예정]
7+
- 메모리: N/A KB
8+
- 시간: N/A ms
9+
---
10+
### 문제 링크
11+
https://code.pusan.ac.kr/problem/4014
12+
### 난이도
13+
보통
14+
### 문제 설명
15+
A시에는개의 쓰레기 소각장이 있다. 각 쓰레기 소각장은 매시간마다 쓰레기를 하나씩 소각할 수 있다.번째 쓰레기가 몇 번째 소각장에서 소각될 지 알아내는 프로그램을 작성해보자.단, 동일한 시간대에 쓰레기를 소각할 수 있는 소각장이 여러 개라면 번호가 빠른 소각장부터 쓰레기를 소각한다
16+
### 입력
17+
첫 번째 줄에 자연수과이 공백으로 구분되어 주어진다.(단,,)두 번째 줄에는 각 쓰레기 소각장의 소각시간가 공백으로 구분되어 주어진다.()
18+
### 출력
19+
번째 쓰레기가 소각되는 소각장 순서와 해당 쓰레기 소각장에서 소각한 쓰레기의 수를 공백으로 구분하여 출력한다.
20+
### 예제 입력/출력
21+
**예제 입력 1**
22+
```
23+
3 14
24+
1 2 3
25+
```
26+
**예제 출력 1**
27+
```
28+
2 4
29+
```
30+
**예제 입력 2**
31+
```
32+
3 24
33+
4 4 5
34+
```
35+
**예제 출력 2**
36+
```
37+
1 9
38+
```
39+
### 힌트
40+
다음은 첫 번째 예시에 대한 설명이다.따라서 14번째 쓰레기는 두 번째 소각장에서 소각되며 총 소각한 쓰레기의 수는 4개이다.
41+
42+
### 제약 사항
43+
- 시간 제한 1000ms
44+
- 메모리 제한 256mb
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
3+
N, M = map(int, sys.stdin.readline().split())
4+
times = list(map(int, sys.stdin.readline().split()))
5+
6+
low = 1
7+
high = max(times) * M
8+
ans_time = high
9+
10+
while low <= high:
11+
mid = (low + high) // 2
12+
13+
total = sum(mid // t for t in times)
14+
15+
if total >= M:
16+
ans_time = mid
17+
high = mid - 1
18+
else:
19+
low = mid + 1
20+
21+
res = sum((ans_time - 1) // t for t in times)
22+
23+
cnt = res
24+
for i in range(N):
25+
if ans_time % times[i] == 0:
26+
cnt += 1
27+
if cnt == M:
28+
print(f"{i + 1} {ans_time // times[i]}")
29+
break

0 commit comments

Comments
 (0)