Skip to content

Commit c0a013a

Browse files
committed
[Silver IV] Title: 로프, Time: 404 ms, Memory: 28392 KB -BaekjoonHub
1 parent 2444423 commit c0a013a

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# [Silver IV] 로프 - 2217
2+
3+
[문제 링크](https://www.acmicpc.net/problem/2217)
4+
5+
### 성능 요약
6+
7+
메모리: 28392 KB, 시간: 404 ms
8+
9+
### 분류
10+
11+
수학, 그리디 알고리즘, 정렬
12+
13+
### 제출 일자
14+
15+
2026년 3월 10일 21:05:05
16+
17+
### 문제 설명
18+
19+
<p>N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다.</p>
20+
21+
<p>하지만 여러 개의 로프를 병렬로 연결하면 각각의 로프에 걸리는 중량을 나눌 수 있다. k개의 로프를 사용하여 중량이 w인 물체를 들어올릴 때, 각각의 로프에는 모두 고르게 w/k 만큼의 중량이 걸리게 된다.</p>
22+
23+
<p>각 로프들에 대한 정보가 주어졌을 때, 이 로프들을 이용하여 들어올릴 수 있는 물체의 최대 중량을 구해내는 프로그램을 작성하시오. 모든 로프를 사용해야 할 필요는 없으며, 임의로 몇 개의 로프를 골라서 사용해도 된다.</p>
24+
25+
### 입력
26+
27+
<p>첫째 줄에 정수 N이 주어진다. 다음 N개의 줄에는 각 로프가 버틸 수 있는 최대 중량이 주어진다. 이 값은 10,000을 넘지 않는 자연수이다.</p>
28+
29+
### 출력
30+
31+
<p>첫째 줄에 답을 출력한다.</p>
32+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class Main {
5+
public static void main(String[] args) throws IOException {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
int N = Integer.parseInt(br.readLine());
8+
9+
Integer[] rope = new Integer[N];
10+
for(int i = 0; i < N; i++){
11+
rope[i] = Integer.parseInt(br.readLine());
12+
}
13+
14+
Arrays.sort(rope, Collections.reverseOrder());
15+
16+
int count = 1;
17+
int max = 0;
18+
19+
for(int i = 0; i < N; i++){
20+
max = Integer.max(rope[i]*count, max);
21+
count++;
22+
}
23+
24+
System.out.println(max);
25+
}
26+
}

0 commit comments

Comments
 (0)