forked from Sahaj-Bamba/HacktoberTrial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDIV3C.cpp
More file actions
90 lines (77 loc) · 1.41 KB
/
DIV3C.cpp
File metadata and controls
90 lines (77 loc) · 1.41 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
map<int,int> mp;
mp[4]=0;
mp[8]=0;
mp[15]=0;
mp[16]=0;
mp[23]=0;
mp[42]=0;
int remove1=0;
for(int i=0;i<n;i++)
{
if(a[i]==4)
mp[4]++;
else if(a[i]==8)
{
if(mp[8]>=mp[4])
{
remove1++;
}
else
{
mp[8]++;
}
}
else if(a[i]==15)
{
if(mp[15]>=mp[8])
{
remove1++;
}
else
{
mp[15]++;
}
}
else if(a[i]==16)
{
if(mp[16]>=mp[15])
remove1++;
else
mp[16]++;
}
else if(a[i]==23)
{
if(mp[23]>=mp[16])
remove1++;
else
mp[23]++;
}
else
{
if(mp[42]>=mp[23])
remove1++;
else
mp[42]++;
}
}
int min1=INT_MAX;
map<int,int> :: iterator it;
for(it=mp.begin();it!=mp.end();it++)
{
min1=min(min1,it->second);
}
for(it=mp.begin();it!=mp.end();it++)
{
remove1+=(it->second-min1);
}
cout<<remove1<<"\n";
}