문제 링크: https://www.acmicpc.net/problem/14456
14456번: Hoof, Paper, Scissors (Bronze)
You have probably heard of the game "Rock, Paper, Scissors". The cows like to play a similar game they call "Hoof, Paper, Scissors". The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each-other. They both count to three and then each s
www.acmicpc.net
가능한 상황이 두가지밖에 없다.
1. 1이 2를 이기고, 2가 3을 이기고, 3이 1을 이기는 경우.
2. 1이 2한테 지고, 2가 3한테 지고, 3이 1한테 지는 경우.
두가지 경우에 대해서 첫번째 소가 이기는 수의 최대값을 구함.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <bits/stdc++.h>
using namespace std;
int N, cnt1, cnt2;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N;
while(N--) {
int a, b;
cin >> a >> b;
if((a == 1 && b == 2) || (a == 2 && b == 3) || (a == 3 && b == 1)) cnt1++;
else if((a == 1 && b == 3) || (a == 3 && b == 2) || (a == 2 && b == 1)) cnt2++;
}
cout << max(cnt1, cnt2) << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 14467 소가 길을 건너간 이유 1 (USACO February 2017 Bronze 1번) (0) | 2020.02.29 |
---|---|
백준 14457 Cow Tipping (USACO January 2017 Bronze 3번) (0) | 2020.02.29 |
백준 14455 Don't Be Last! (USACO January 2017 Bronze 1번) (0) | 2020.02.28 |
백준 14175 The Cow-Signal (USACO December 2016 Bronze 3번) (0) | 2020.02.28 |
백준 14174 Block Game (USACO December 2016 Bronze 2번) (0) | 2020.02.28 |