#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
int studentNum,max;
int minRoom = 0;
int sex, grade;
int arrGirl[6] = {0,}; //각 학년의 수를 담을 배열 0이면 여자
int arrMan[6] = {0,}; //각 학년의 수를 담을 배열 1이면 남자
cin >> studentNum >> max;
for (int i = 0; i < studentNum; i++) {
cin >> sex >> grade;
if (sex == 0)
arrGirl[grade - 1]++;
else
arrMan[grade - 1]++;
}
for (int i = 0; i < 6;i++) {
if (arrGirl[i] != 0) {
if (arrGirl[i] <= max)
minRoom++;
else {
if (arrGirl[i] % max == 0) {
minRoom += arrGirl[i] / max;
}
else
minRoom += (arrGirl[i] / max) + 1;
}
}
}
for (int i = 0; i < 6; i++) {
if (arrMan[i] != 0) {
if (arrMan[i] <= max)
minRoom++;
else {
if (arrMan[i] % max == 0) {
minRoom += arrMan[i] / max;
}
else
minRoom += (arrMan[i] / max) + 1;
}
}
}
cout << minRoom;
}
3번이나 틀렸습니다가 떠버렸네.. 내 정답률..
항상 내가 구현한 코드가 맞는 것 같은데
결국 다시 하나하나보면 실수가 있네ㅋㅋㅋ
'BOJ' 카테고리의 다른 글
[백준] 11328번 Strfry C++ (0) | 2020.04.21 |
---|---|
[백준] 1475번 방 번호 c++ (0) | 2020.04.21 |
[백준] 10807번 개수 세기 c++ (0) | 2020.04.20 |
[백준] 10808번 알파벳 개수 C++ (0) | 2020.04.20 |
[백준] 2309번 일곱 난쟁이 c++ (0) | 2020.04.20 |