[백준] P11399

4449 단어 algorithmalgorithm
import java.util.Arrays;
import java.util.Scanner;

public class P11399 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int answer = 0, n = sc.nextInt(), a[] = new int[n], acc = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		for (int ele : a) {
			acc += ele;
			answer += acc;
		}
		System.out.println(answer);
		sc.close();

	}
}

좋은 웹페이지 즐겨찾기