MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / calcu

Function calcu

Codeforces_problems/Subset Mex/solutions.cpp:10–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
9#define endl '\n'
10int calcu(vector<int>&v)
11{
12
13 map<int,int>m;
14 int i,b,c;
15 b=-1,c=-1;
16 for(i=0;i<v.size();i++)
17 {
18 m[v[i]]++;
19 }
20 for(i=0;i<v.size()+1;i++)
21 {
22 if(m[i]>0)m[i]--;
23 else
24 {
25 b=i;
26 break;
27 }
28 }
29 for(i=0;i<v.size()+1;i++)
30 {
31 if(m[i]>0)m[i]--;
32 else
33 {
34 c=i;
35 break;
36 }
37 }
38 v.clear();
39
40 return b+c;
41}
42 int main()
43 {
44 optimize();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected