Created
January 13, 2020 05:42
-
-
Save dalcon10028/c07623c81e83dbf3fd4cd10f87645078 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class Main { | |
| public static void main(String args[]) { | |
| Scanner sc = new Scanner(System.in); | |
| int N = sc.nextInt(); | |
| int []person = new int[N]; | |
| for(int i=0; i<N; i++) | |
| person[i] = sc.nextInt(); | |
| sc.close(); | |
| Arrays.sort(person); | |
| int result = 0; | |
| for(int i=0; i<N; i++) | |
| for(int j=0; j<=i; j++) | |
| result+=person[j]; | |
| System.out.print(result); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment