Dev.baelanche

[백준 14582] 오늘도 졌다 본문

Data Structure & Algorithm/PS - JAVA

[백준 14582] 오늘도 졌다

baelanche 2019. 7. 17. 21:24
반응형

 

중간에 단 한번이라도 울림 제미니스의 점수가 높은지를 체크해야한다.

1회초, 1회말 ...... 9회초, 9회말 순으로 점수를 비교하며 한번이라도 울림쪽이 이기고 있다면 Yes를 출력해주자.

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a[] = new int[9];
        for(int i=0; i<9; i++)
            a[i] = sc.nextInt();
        
        int b[] = new int[9];
        for(int i=0; i<9; i++)
            b[i] = sc.nextInt();
        
        int ulim = 0;
        int stl = 0;
        for(int i=0; i<9; i++) {
            ulim += a[i];
            if(ulim > stl) {
                System.out.println("Yes");
                return;
            }
            stl += b[i];
        }
        
        System.out.println("No");
    }
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 14585] 사수빈탕  (0) 2019.07.17
[백준 14584] 암호 해독  (0) 2019.07.17
[백준 11947] 이런 반전이  (0) 2019.07.17
[백준 11946] ACM-ICPC  (0) 2019.07.17
[백준 2420] 사파리 월드  (0) 2019.07.16
Comments