Skip to content

Instantly share code, notes, and snippets.

@dalcon10028
Created January 13, 2020 05:42
Show Gist options
  • Select an option

  • Save dalcon10028/c07623c81e83dbf3fd4cd10f87645078 to your computer and use it in GitHub Desktop.

Select an option

Save dalcon10028/c07623c81e83dbf3fd4cd10f87645078 to your computer and use it in GitHub Desktop.
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