https://www.acmicpc.net/problem/13304
#include<stdio.h>
static int num(int sum,int k){
int room=sum%k;
int c=0;
if(room==0) c=sum/k;
else c=(sum/k)+1;
return c;
}
int main() {
int n,k;
scanf("%d %d",&n,&k);
int boy[6]={};
int girl[6]={};
int count=0;
for(int i=0;i<n;i++){
int e,y;
scanf("%d %d",&e,&y);
if(e==0) girl[y-1]++;
else boy[y-1]++;
}
int sum=0;
for(int i=0;i<6;i+=2){
if(i==0){
sum=boy[i]+boy[i+1]+girl[i]+girl[i+1];
count+=num(sum,k);
}
else{
sum=boy[i]+boy[i+1];
count+=num(sum,k);
sum=girl[i]+girl[i+1];
count+=num(sum,k);
}
}
printf("%d",count);
}