Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BOJ_16208_당현아 #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
hadevyi merged 1 commit into main from eona1301_previous_algo
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
static int N, Total;
static int[] arr;

public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

N = Integer.parseInt(br.readLine());
arr = new int[N];

StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0;i<N;i++) {
int n = Integer.parseInt(st.nextToken());
Total += n;
arr[i] = n;
}

Arrays.sort(arr);

long Result = 0;
for(int i=0;i<N;i++) {
Result += arr[i] * (Total-arr[i]);
Total -= arr[i];
}
System.out.println(Result);
}
}

AltStyle によって変換されたページ (->オリジナル) /