728x90
10162 전자레인지 [브론즈4]
https://www.acmicpc.net/problem/10162
import java.util.Scanner;
//A:300초 B:60초 C:10초
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
if (T%10 != 0) {
System.out.println("-1");
return ;
}
System.out.print("" + (T/300) +" ");
T = T%300;
System.out.print("" + (T/60) +" ");
T = T%60;
System.out.print("" + (T/10));
}
}
2720 세탁소 사장 동혁 [브론즈3]
https://www.acmicpc.net/problem/2720
import java.util.ArrayList;
import java.util.Scanner;
//25 10 5 1
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//테스트케이스 개수
int T = sc.nextInt();
ArrayList<Integer> arr = new ArrayList<Integer>();
for (int i = 0; i<T; i++) {
arr.add(sc.nextInt());
}
for (Integer money : arr) {
System.out.print("" + (int)money/25 + " ");
money %= 25;
System.out.print("" + (int)money/10 + " ");
money %= 10;
System.out.print("" + (int)money/5 + " ");
money %= 5;
System.out.print("" + money);
System.out.println();
}
}
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
//25 10 5 1
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//테스트케이스 개수
int T = Integer.parseInt(br.readLine());
ArrayList<Integer> arr = new ArrayList<Integer>();
for (int i = 0; i<T; i++) {
arr.add(Integer.parseInt(br.readLine()));
}
for (Integer money : arr) {
System.out.print("" + (int)money/25 + " ");
money %= 25;
System.out.print("" + (int)money/10 + " ");
money %= 10;
System.out.print("" + (int)money/5 + " ");
money %= 5;
System.out.print("" + money);
System.out.println();
}
}
}
11034 캥거루 세마리2 [브론즈3]
https://www.acmicpc.net/problem/11034
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s;
while ((s=br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(s);
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
int C = Integer.parseInt(st.nextToken());
int maxLength = Math.max(B-A-1 , C-B-1);
System.out.println(maxLength);
}
}
}
14720 우유축제 [브론즈3]
https://www.acmicpc.net/problem/14720
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int turn = 0;
int result = 0;
for (int i = 0; i<N; i++) {
int store = Integer.parseInt(st.nextToken());
if (turn == store) {
result += 1;
turn = (turn + 1) % 3;
}
}
System.out.println(result);
}
}
2864 5와 6의 차이 [브론즈2]
https://www.acmicpc.net/problem/2864
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
String A = st.nextToken();
String B = st.nextToken();
int min = 0;
int max = 0;
A = A.replace("6", "5");
B = B.replace("6", "5");
min = Integer.parseInt(A) + Integer.parseInt(B);
A = A.replace("5", "6");
B = B.replace("5", "6");
max = Integer.parseInt(A) + Integer.parseInt(B);
System.out.println("" + min + " " + max);
}
}
5585 거스름돈 [브론즈2]
https://www.acmicpc.net/problem/5585
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int money = 1000 - Integer.parseInt(bf.readLine());
int result = 0;
int[] type = {500, 100, 50, 10, 5, 1};
for (int t : type) {
result += money / t;
money = money%t;
if (money == 0) {
break;
}
}
System.out.println(result);
}
}
14487 욱제는 효도쟁이야!! [브론즈2]
https://www.acmicpc.net/problem/14487
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
StringTokenizer st = new StringTokenizer(bf.readLine());
int max = 0;
int result = 0;
for (int i =0; i<n; i++) {
int tmp = Integer.parseInt(st.nextToken());
max = (max < tmp)? tmp : max;
result += tmp;
}
result -= max;
System.out.println(result);
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(bf.readLine());
StringTokenizer st = new StringTokenizer(bf.readLine());
int max = 0;
int result = 0;
for (int i =0; i<n; i++) {
int tmp = Integer.parseInt(st.nextToken());
max = (max < tmp)? tmp : max;
result += tmp;
}
result -= max;
bw.write(String.valueOf(result));
bw.flush();
bw.close();
}
}
14471 포인트 카드 [브론즈2]
https://www.acmicpc.net/problem/14471
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(bf.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
int min = 2*N;
int result = 0;
for (int i =0 ; i< M; i++) {
st = new StringTokenizer(bf.readLine());
int A = Integer.parseInt(st.nextToken());
result += (N-A>0)? N-A : 0;
min = (min > A)? A : min;
}
System.out.println(result - ((N-min > 0)? N-min : 0));
}
}
2810 컵홀더 [브론즈1]
https://www.acmicpc.net/problem/2810
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
bf.readLine();
String str = bf.readLine();
//stream 사용
long cnt = str.chars().filter(c->c == 'L').count();
//replace 사용
// long cnt2 = str.length() - str.replace(String.valueOf("L"), "").length();
cnt = (cnt != 0)? cnt/2-1 : 0;
System.out.println(str.length() - cnt);
}
}
2930 가위 바위 보 [브론즈1]
https://www.acmicpc.net/problem/2930
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String type = "SRP";
//result
int sanResult = 0;
int bestResult = 0;
//input
int roundNum = Integer.parseInt(bf.readLine());
String sanguen = bf.readLine();
int frdNum = Integer.parseInt(bf.readLine());
ArrayList<String> frds = new ArrayList<>();
for (int i =0; i<frdNum; i++) {
frds.add(bf.readLine());
}
for (int i =0; i<roundNum; i++) {
int[] cnt = {0,0,0};
int sIdx = type.indexOf(sanguen.charAt(i));
for (int j = 0; j<frdNum; j++) {
cnt[type.indexOf(frds.get(j).charAt(i))] += 1;
}
bestResult += max(cnt[0] + cnt[2]*2, cnt[1]*2+cnt[2], cnt[0]*2+cnt[1]);
sanResult += cnt[sIdx] + cnt[(sIdx+2)%3] * 2;
}
System.out.println(sanResult);
System.out.println(bestResult);
}
public static int max(int a, int b, int c) {
return Math.max(a, Math.max(b,c));
}
}
4796 캠핑 [브론즈1]
https://www.acmicpc.net/problem/4796
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
int cnt = 1;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String tmp = bf.readLine();
while (tmp.charAt(0) != '0') {
StringTokenizer st = new StringTokenizer(tmp);
int L = Integer.parseInt(st.nextToken());
int P = Integer.parseInt(st.nextToken()); //연속하는 P일 중 L일동안 사용가능
int V = Integer.parseInt(st.nextToken()); //강산이 휴가기간
int result = V/P * L + ((V%P < L)? V%P : L);
System.out.println("Case "+cnt+": "+result);
cnt ++;
tmp = bf.readLine();
}
}
}
728x90
'알고리즘 > 백준' 카테고리의 다른 글
[Java] bfs 실버모음3 (0) | 2023.02.11 |
---|---|
[Java] bfs 실버모음2 (0) | 2023.02.10 |
[Java] bfs 실버 모음1 (0) | 2023.02.09 |
백준 greedy 실버5 모음1 - 파이썬 (2) | 2023.01.04 |
백준 greedy 브론즈 모음 - 파이썬 (4) | 2023.01.02 |