민주주의 (백준 30999)

코딩생활·2023년 12월 28일
0

백준문제풀이

목록 보기
144/308

안녕하세요. 오늘은 민주주의적 판단을 할 거예요.

문제

https://www.acmicpc.net/problem/30999

아이디어

한 줄에서 O의 개수가 M/2개를 넘으면 cnt++해주면 됩니다.

소스코드

#include <iostream>
#include <string>
using namespace std;


int main(void)
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N, M, i, ans = 0, cnt;
    string s;

    cin >> N >> M;
    for (i = 0; i < N; i++)
    {
        cnt = 0;
        cin >> s;
        for (char c : s)
            if (c == 'O')
                cnt++;
        if (cnt > M / 2) ans++;
    }
    cout << ans;
}


감사합니다.

0개의 댓글