CodeChef::VOTERS

 #include <bits/stdc++.h>
using namespace std ;
#define boost ios::sync_with_stdio(0);cin.tie(0)
#define ll long long

int main(){

boost ;
ll n1,n2,n3,n ;
cin >> n1 >> n2 >> n3 ;
n = n1+n2+n3 ;
ll arr[n];
for(ll i = 0; i < n ; i++){
    cin >> arr[i] ;

}
vector <ll> v ;
ll count{1},first_elmt;
sort(arr,arr+n);
first_elmt = arr[0];
for(ll i =1;i<n;i++){
    if(first_elmt == arr[i]){
        count ++ ;
    }
    else{
        if(count >= 2)
        {
            v.push_back(first_elmt);
        }
        first_elmt = arr[i];
        count = 1;
    }
}
cout << v.size() << '\n' ;
for(ll i = 0;i<v.size();i++){
    cout << v[i] << '\n';
}


return 0 ;
}

Comments

Popular posts from this blog

CodeChef::CSUB

How Recursion Works?

CodeChef::TREE2