import java.util.Arrays; import java.util.Scanner; public class Main { static int[] p; static int N; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); p = new int[N]; for (int i = 0; i < p.length; i++) p[i] = sc.nextInt(); Arrays.sort(p); int result = p[0]; for (int i = 1; i < p.length; i++) { p[i] = p[i-1] + p[i]; result += p[i]; } System.out.printl..
알고리즘
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static Queue q = new LinkedList(); static int[][] map; static boolean[][] visited; static int[] dx = {-1,1,0,0}; static int[] dy = {0,0,-1,1}; static int N; static int M; public static class Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } } public static void bfs(Queue q) { wh..
import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int[][] map; static boolean[][] visited; static ArrayList list = new ArrayList(); static int[] dx = {-1,1,0,0}; static int[] dy = {0,0,-1,1}; static int N; public static class Point { int x; int y; Point(int x, int y) { this.x = x; th..
import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int[] Min = new int[100005]; static int N; static int K; public static int bfs(int n, int k, int[] min) { Queue q = new LinkedList(); q.add(n); int move[] = new int[3]; Min[n] = 0; int next = n; while(!q.isEmpty() && next != k) { next = q.poll(); move[0] = next - 1; ..
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int[][] arr; static boolean visited[][]; static int[] dx = {-1, 0, 1, 0}; static int[] dy = {0, -1, 0, 1}; static int N; static int M; static class Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } } public static void bfs(int x, int y) { Queue q = new LinkedList(); q.add..
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int[][] graph; static boolean visited[]; static int N; static int M; static int start; public static void dfs(int i) { visited[i] = true; System.out.print(i + " "); for (int j = 1; j