-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj_2217.java
More file actions
31 lines (24 loc) · 785 Bytes
/
boj_2217.java
File metadata and controls
31 lines (24 loc) · 785 Bytes
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
29
30
31
package greedy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class boj_2217 {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
Integer[] rope=new Integer[n];
int weight=Integer.MIN_VALUE;
for(int i=0;i<n;i++){
rope[i]=Integer.parseInt(br.readLine());
}
Arrays.sort(rope, Collections.reverseOrder());
for(int i=0;i<n;i++){
if(rope[i]*(i+1)>weight){
weight=rope[i]*(i+1);
}
}
System.out.println(weight);
}
}