January 2022 enrollments are closed and the course commences on 8th of January, 2022. For future cohorts

EGYPIZZA Solution

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int min ( int a , int b ){
if ( a < b )
return a;
return b;
}

int main ( int argc , char * argv[] ) {

int t;

while ( scanf("%d" , &t) != EOF ) {

int s;

memset(s,0,sizeof(s));

while ( t-- ) {

char str;

scanf("%s" , str );

if ( str == '1' && str == '4' ) {
s++;
}
else if ( str == '1' && str == '2' ) {
s++;
}
else if ( str == '3' && str == '4' ) {
s++;
}

}

// Abotrika's 1 pizza
int n = 1;
int d = 0;

d = min( s , s );
n += d;
s -= d;
s -= d;

//Combining two 1/2 into 1 pizza
n += s/2;
s = s % 2;

//Combining 2 1/4th and 1 1/2

if ( s == 1 && s >= 2 ) {
n += 1;
s -= 2;
s = 0;
}

if ( s == 1 && s == 1 ) {
n += 1;
s = 0;
s = 0;
}

//Combining 2 1/4th and 1 1/2
d = min ( s/4 , s);
n += d;
s -= (2 * d);
s -= d;

//Combingin all 1/4ths
n += s/4;
if ( s % 4 == 0 )
s = 0;
else
s = 1;

// Rest all will be comming form 1 pizza each

n += (s + s + s);

printf("%d\n" , n);
}

return 0;
}