백준 25496번
import java.util.Arrays;
import java.util.Scanner;
public class problem477 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt(); // 피로도
int size = in.nextInt(); // 장신구 갯수
int[] arr = new int[size];
int count = 0;
for (int i = 0; i < size; i++) {
arr[i] = in.nextInt();
}
Arrays.sort(arr);
int index = 0;
// 탐색
while (num < 200 && index < arr.length) {
num += arr[index++];
count++;
}
System.out.println(count);
}
}
백준 25644번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class problem478 {
public static void main(String[] args) throws IOException {
BufferedReader input =
new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(input.readLine()); // 갯수
int[] arr = new int[num]; // 주가 배열
String[] value = input.readLine().split(" ");
for (int i = 0; i < num; i++) {
arr[i] = Integer.parseInt(value[i]);
}
int max = 0;
int min = Integer.MAX_VALUE;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < min) {
min = arr[i]; // 최소 주가 할당
} else {
int temp = arr[i] - min;
max = Math.max(max, temp); // 최대값 할당
}
}
System.out.println(max);
}
}
백준 24313번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class problem479 {
public static void main(String[] args) throws IOException {
BufferedReader input =
new BufferedReader(new InputStreamReader(System.in));
String[] f = input.readLine().split(" ");
int f1 = Integer.parseInt(f[0]);
int f2 = Integer.parseInt(f[1]);
int c = Integer.parseInt(input.readLine());
int n = Integer.parseInt(input.readLine());
int tempA = f1 * n + f2;
int tempB = c * n;
if (tempA <= tempB && f1 <= c) {
System.out.println(1);
} else {
System.out.println(0);
}
}
}