백준

백준 20115번: 에너지 드링크 (파이썬, 자바)

inns21 2023. 7. 29. 23:03

# 파이썬

n = int(input())
n_list = list(map(int, input().split()))
n_list.sort(reverse=True)

result = n_list.pop(0)
result += sum([i/2 for i in n_list])
print(result)

 

// 자바

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int count = sc.nextInt();
		sc.nextLine();
		
		String[] drinks = sc.nextLine().split(" ");
		List<Double> dList = new ArrayList<>();
		
		for(String d:drinks) {
			dList.add(Double.parseDouble(d));
		}
		
		 Collections.sort(dList, Collections.reverseOrder());
		 
		 Double result = dList.get(0);
		 
		 for(int i=1; i < dList.size(); i++) {
			 result += (dList.get(i)/2);
		 }
		 System.out.println(result);
	}

}