import java.util.Arrays; import java.util.Scanner; public class Main { static int N; static int[] K; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); K = new int[N]; for (int i = 0; i =0; i--) { K[i] = K[i]*(N-i); if (max < K[i]) max = K[i]; } System.out.println(ma..
알고리즘/연습문제
import java.util.Scanner; public class Main { static int[] money = {500, 100, 50, 10, 5, 1}; static int pay; public static void main(String[] args) { Scanner sc = new Scanner(System.in); pay = sc.nextInt(); int change = 1000 - pay; int result = 0; for (int i = 0; i = money[i]) { result += change/money[i]; change = change%money[i]; } } System.out.println(result); } }
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { static int[][] conference; static int N; static int K; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); conference = new int[N][2]; for (int i = 0; i < N; i++) { for (int j = 0; j < 2; j++) { conference[i][j] = sc.nextInt(); } } Arrays.sort(conference..
import java.util.Scanner; public class Main { static int[] coin; static int N; static int K; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); K = sc.nextInt(); coin = new int[N]; for (int i = 0; i = 0; i--) { if (coin[i]
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; ..