본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 4299번 AFC 윔블던

by 현장 2022. 4. 16.

-Code

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int scoreSum = sc.nextInt();
        int scoreMinus = sc.nextInt();
        int team1 = scoreSum + scoreMinus;
        int team2 = scoreSum - scoreMinus;

        if (team1 % 2 != 0 && team2 % 2 != 0) {
            System.out.println(-1);
        } else {
            if (team1 / 2 >= 0 && team2 / 2 >= 0) {
                System.out.println(team1 / 2 + " " + team2 / 2);
            } else {
                System.out.println(-1);
            }
        }
    }
}