๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm

[Codeforces] 703A: Mishka and Game

by ์ฃผ๋ฐœ2 2020. 3. 4.
๋ฐ˜์‘ํ˜•

https://codeforces.com/problemset/problem/703/A

 

Problem - 703A - Codeforces

 

codeforces.com

์ฝ”๋“œ

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int Mishka = 0;	// Mishak wins
		int Chris = 0;	// Chris wins
		String result = "";
		for(int i=0; i<n; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			Mishka += (a > b) ? 1 : 0;
			Chris  += (b > a) ? 1 : 0;
		}
		
		result = (Mishka > Chris) ? "Mishka" : (Mishka == Chris) ? "Friendship is magic!^^" : "Chris" ;
		System.out.println(result);
		scan.close();
	}

}

ํ’€์ด

๋ˆ„๊ฐ€ ๋” ๋งŽ์ด ์ด๊ธด์ง€ ๋น„๊ตํ•ด์„œ ์ถœ๋ ฅ

3ํ•ญ์—ฐ์‚ฐ์ž๋ฅผ ํ†ตํ•ด if๋ฌธ์„ ๊ฐ„๋‹จํžˆ ๋‚˜ํƒ€๋ƒˆ๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€