Algorithm

BOJ 13300 방 배정 c++

최강훈 2020. 8. 14. 20:46

BOJ 13300 방 배정 c++

백준 13300 방 배정 c++


#include <bits/stdc++.h>
using namespace std;

int boy[8];
int girl[8];
int n, k;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    while (n--) {
        int gender, grade;
        cin >>  gender >> grade;
        if (gender == 0) {
            girl[grade]++;
        } else {
            boy[grade]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= 6; i++) {
        while (boy[i] > 0) {
            ans++;
            boy[i] -= k;
        }
        while (girl[i] > 0) {
            ans++;
            girl[i] -= k;
        }
    }
    cout << ans;

}