문제 링크입니다: https://www.acmicpc.net/problem/8714
8714번: Monety
Pierwszy wiersz wejścia zawiera jedną liczbę całkowitą n (1 ≤ n ≤ 106), oznaczająca liczbę monet Bajtka. Kolejny wiersz zawiera ciąg n liczb całkowitych a1, a2, ..., an, gdzie ai oznacza opis i-tej monety, 0 - jeśli moneta leży na awers
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n; | |
cin >> n; | |
int headCnt = 0, tailCnt = 0; | |
for (int i = 0; i < n; i++) | |
{ | |
bool tail; | |
cin >> tail; | |
tail ? tailCnt++ : headCnt++; | |
} | |
int result = min(headCnt, tailCnt); | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 8719번 Piłeczka (0) | 2021.06.27 |
---|---|
백준 8716번 Pole (0) | 2021.06.27 |
백준 8713번 Znak działania (0) | 2021.06.27 |
백준 8678번 Zbiór (0) | 2021.06.27 |
백준 8674번 Tabliczka (0) | 2021.06.27 |