๊ธฐ๋ก๋ฐฉ

BOJ_2520 : ํŒฌ์ผ€์ดํฌ ์‚ฌ๋ž‘ ๋ณธ๋ฌธ

CodingTest/Java

BOJ_2520 : ํŒฌ์ผ€์ดํฌ ์‚ฌ๋ž‘

Soom_1n 2022. 12. 1. 16:30

๐Ÿ‘‰ ๋ฌธ์ œ๋งํฌ

 

2520๋ฒˆ: ํŒฌ์ผ€์ดํฌ ์‚ฌ๋ž‘

  ์ฒซ ๋ฒˆ์งธ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์—์„œ ์ฃผ์–ด์ง„ ์žฌ๋ฃŒ๋ฅผ ๊ฐ€์ง€๊ณ  ๋ฐ”๋‚˜๋‚˜ ํŒฌ์ผ€์ต 10๊ฐœ, ๋”ธ๊ธฐ ํŒฌ์ผ€์ต 1๊ฐœ, ์ดˆ์ฝœ๋ฆฟ ํŒฌ์ผ€์ต 4๊ฐœ, ํ˜ธ๋‘ ํŒฌ์ผ€์ต 1๊ฐœ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.   ๋‘ ๋ฒˆ์งธ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์—์„œ ์ฃผ์–ด์ง„ ์žฌ๋ฃŒ ์ค‘ ๋ฐ€

www.acmicpc.net



๐Ÿ”ธ ๋ฌธ์ œ ๋ถ„์„ ๐Ÿ”ธ

  • ๋ฐ˜์ฃฝ ์žฌ๋ฃŒ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋ฐ˜์ฃฝ์˜ ์ตœ๋Œ€๊ฐ’์„ ๊ตฌํ•˜๊ณ , ํ† ํ•‘ ์žฌ๋ฃŒ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ์ผ€์žŒ์˜ ์ตœ๋Œ€๊ฐ’์„ ๊ตฌํ•ด ๋น„๊ตํ•ด์„œ ๋” ์ž‘์€๊ฐ’์„ ์ถœ๋ ฅํ•œ๋‹ค.
  • ๋ฐ˜์ฃฝ์˜ ์žฌ๋ฃŒ๋Š” ์ผ๋ถ€๋งŒ ๋„ฃ์€ ๋ฐฐ์œจ๊ฐ’์œผ๋กœ๋„ ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ floatํ˜•์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.(ํžŒํŠธ2๋ฒˆ)

๐Ÿ”ธ ์ฝ”๋“œ ๐Ÿ”ธ

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        int[] banjuk_list = {8, 8, 4, 1, 9};
        int[] toping_list = {1, 30, 25, 10};

        for (int i = 0; i < t; i++) {
            br.readLine();
            StringTokenizer st = new StringTokenizer(br.readLine());
            float banjuk = 1000000;
            for (int j = 0; j < 5; j++) {
                float b = Float.parseFloat(st.nextToken());
                if (b / banjuk_list[j] < banjuk)
                    banjuk = b / banjuk_list[j];
            }
            banjuk = (int)(banjuk * 16);

            st = new StringTokenizer(br.readLine());
            int toping = 0;
            for (int j = 0; j < 4; j++) {
                int p = Integer.parseInt(st.nextToken());
                toping += p / toping_list[j];
            }
            System.out.println((int)(banjuk < toping ? banjuk:toping));
        }
    }
}

๐Ÿ”ธ ์ฝ”๋“œ ํ•ด์„ ๐Ÿ”ธ

  • ๋ฐ˜์ฃฝ, ํ† ํ•‘ ๊ฐ’์„ ๋ฐฐ์—ด์— ์ €์žฅํ•ด๋‘๊ณ  ์‚ฌ์šฉํ•œ๋‹ค.
  • ๋ฐ˜์ฃฝ์˜ int ์บ์ŠคํŒ… ๊ฐ’๊ณผ ํ† ํ•‘ ํ•ฉ๊ณ„๋ฅผ ๋น„๊ตํ•˜๊ณ , ์ž‘์€ ๊ฐ’์„์ถœ๋ ฅํ• ๋•Œ intํ˜•์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค.

๐Ÿ”ธ end ๐Ÿ”ธ

  • ์กฐ๊ฑด์„ ๋งž์ถ”๊ธฐ ์œ„ํ•ด ๋งŽ์ด ๊ณ ์ƒํ–ˆ๋˜ ๋ฌธ์ œ์˜€๋‹ค.

728x90

'CodingTest > Java' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

BOJ_4158 : CD  (0) 2022.12.01
BOJ_3447 : ๋ฒ„๊ทธ์™•  (0) 2022.12.01
BOJ_2193 : ์ด์นœ์ˆ˜  (0) 2022.11.29
BOJ_13699 : ์ ํ™”์‹  (0) 2022.11.29
BOJ_9625 : BABBA  (0) 2022.11.24