forked from himanshu-dixit/CodeForces-Solution
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path158B-TAXI.cpp
More file actions
39 lines (32 loc) · 840 Bytes
/
158B-TAXI.cpp
File metadata and controls
39 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int group_total,i,k;
cin>>group_total;
//int* student_group = (int *) malloc(sizeof(int)*group_total); Use if want to DMAelse
int student_group[5]={0}; //intializing all elements with zero
for(i=0;i<group_total;i++){
cin>>k;
student_group[k]++;
}
int taxi=0;
taxi+=student_group[4];
taxi+=student_group[3];
student_group[1]=student_group[1]-student_group[3];
student_group[1]=student_group[1]<0?0:student_group[1];
if(student_group[1]<0){
student_group[1]=0;
}
taxi+=student_group[2]/2+student_group[2]%2;
student_group[2]=student_group[2]%2;
student_group[1] = student_group[1]-2*(student_group[2]);
if(student_group[1]>0){
taxi+=(student_group[1])/4;
if(student_group[1]%4>0){
taxi++;
}
}
cout<<taxi; //Output the no of taxi neesded by the group
return 0;
}