백준 308082번 (노가다)

김경욱·2026년 1월 24일

백준

목록 보기
114/121

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

// Press Shift twice to open the Search Everywhere dialog and type show whitespaces,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int participantCount = Integer.parseInt(br.readLine());
    StringTokenizer st = new StringTokenizer(br.readLine());
    int S = Integer.parseInt(st.nextToken());
    int M = Integer.parseInt(st.nextToken());
    int L = Integer.parseInt(st.nextToken());
    int XL = Integer.parseInt(st.nextToken());
    int XXL = Integer.parseInt(st.nextToken());
    int XXXL = Integer.parseInt(st.nextToken());

    st = new StringTokenizer(br.readLine());
    int tShirt = Integer.parseInt(st.nextToken()); //묶음수 5개
    int pen = Integer.parseInt(st.nextToken()); //묶음수 7개





    if(S%tShirt == 0) {
        S = S / tShirt;
    } else {
        S = S / tShirt +1;
    }
    if(M%tShirt == 0){
        M=M/tShirt;
    }
    else {
        M = M / tShirt +1;
    }
    if(L%tShirt == 0){
        L=L/tShirt;
    }
    else {
        L = L / tShirt +1;
    }
    if(XL%tShirt == 0){
        XL=XL/tShirt;
    }
    else {
        XL = XL / tShirt +1;
    }
    if(XXL%tShirt == 0){
        XXL=XXL/tShirt;
    }
    else {
        XXL = XXL/ tShirt +1;
    }
    if(XXXL%tShirt == 0){
        XXXL=XXXL/tShirt;
    } else {
        XXXL = XXXL / tShirt +1;
    }

    System.out.println(S+M+L+XL+XXL+XXXL);






    int share = participantCount / pen;
    int rest = participantCount % pen;
    System.out.println(share+" "+rest);






}

}
애초에 변수를 S,M,L이런 식으로 받지 않고 그냥 배열로 입력 받는게 훨씬 깔끔함!

0개의 댓글