๋ฐ์ํ
https://codeforces.com/problemset/problem/703/A
์ฝ๋
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๋ฌธ์ ๊ฐ๋จํ ๋ํ๋๋ค.
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 13300๋ฒ: ๋ฐฉ ๋ฐฐ์ (๊ตฌํ) (0) | 2020.03.04 |
---|---|
ํ๋ก๊ทธ๋๋จธ์ค[Java] - K๋ฒ์งธ์(์ ๋ ฌ) (0) | 2020.03.04 |
[๋ฐฑ์ค] 1051๋ฒ: ์ซ์ ์ ์ฌ๊ฐํ(์์ ํ์, ๊ตฌํ) (0) | 2020.03.03 |
[๋ฐฑ์ค] 4948๋ฒ: ๋ฒ ๋ฅดํธ๋ ๊ณต์ค(์์, ์๋ผํ ์คํ ๋ค์ค์ ์ฒด) (0) | 2020.03.03 |
ํ๋ก๊ทธ๋๋จธ์ค[Java] - ๋ฉ๋ฆฌ ๋ฐ๊ธฐ(DP) (0) | 2020.03.03 |
๋๊ธ