백준

백준 - 11399번

가평잣막걸리 2024. 7. 9. 11:10

public class No_11399 {

	public static void main(String[] args) {  
		
		 Scanner sc = new Scanner(System.in);
			
	     int n = Integer.parseInt(sc.nextLine()) ;  // 사람 수 N
	        
	     int[] str = new int[n]; 
	     String input = sc.nextLine();
	        
	        for(int i=0; i<str.length; i++){
	        	str[i] = Integer.parseInt(input.split(" ")[i]);
	        	
	        	// System.out.print(str[i]+" ");
	        }
	        Arrays.sort(str);

	        
	        int result = 0;
	        //int sum = 0;
	        
	        for(int i=0; i<n; i++){
	        	for(int j=0; j<=i; j++) {
	        		result += str[j];
	        	}
	        	//System.out.print(str[i]+" ");
	        	//System.out.print(str2[i]+" ");
	        }
	        
	        System.out.println(result);
	        
	        sc.close();
			
	}

 

 

'백준' 카테고리의 다른 글

백준 - 1026번  (0) 2024.07.09