#include <stdio.h>

int main() {
    int man_grade[6]={0};
    int woman_grade[6]={0};
    int room=0;
    int std_num,k;
    int s,y;
    scanf("%d %d",&std_num ,&k);
    while (std_num--) {
        //학생 성별 학년 입력
        scanf("%d %d",&s, &y);
        if (s==1) {
            man_grade[y-1]+=1;
        } else {
            woman_grade[y-1]+=1;
        }
    }
    for (int i=0; i<6; i++) {
            if (man_grade[i]%k!=0) {
                room=room+1+man_grade[i]/k;
            } else {
                room+= man_grade[i]/k;
            }
            if (woman_grade[i]%k!=0) {
                room=room+1+woman_grade[i]/k;
            } else {
                room+= woman_grade[i]/k;
            }
        }
    printf("%d",room);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: