티스토리 뷰

BOJ

BOJ/백준온라인/1267번

최잼 2016. 1. 14. 15:46
import java.util.Scanner;
 
class YeungSik{
    int total;
     
    void sum(int[] newtime){
         
        for(int i=0;i<newtime.length;i++){
             
            int result=0;
            while(newtime[i]>=0)
            {
                result+=10;
                newtime[i]-=30;
            }
             
            this.total=this.total+result;
        }
    }
}
 
class MinSik{
    int total;
     
    void sum(int[] newtime){
         
        for(int i=0;i<newtime.length;i++){
            int result=0;
            while(newtime[i]>=0)
            {
                result+=15;
                newtime[i]-=60;
            }
             
            total=total+result;
        }
    }
}
 
class Main{
    public static void main(String args[]){
         
        Scanner scan = new Scanner(System.in);
         
        int N= scan.nextInt();
        int[] time= new int[N];
        int[] time2= new int[N];
         
     
        for(int i=0; i<N;i++){
            time[i]=scan.nextInt();
            time2[i]=time[i];
        }
         
         
        YeungSik ys= new YeungSik();
        ys.sum(time);
         
        MinSik ms= new MinSik();
        ms.sum(time2);
         
     
        if(ms.total==ys.total)
            System.out.println("Y M "+ys.total);
     
        else if(ms.total>ys.total)
            System.out.println("Y "+ys.total);
        else
            System.out.println("M "+ms.total);
     
         
         
         
         
    }
    }


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함