Cod sursa(job #3273885)

Utilizator postoocezar andrei mihai tutunaru tambozi teodor lot postoo Data 4 februarie 2025 12:06:42
Problema Elementul majoritar Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

map <int , int>frecv;

int main()
{
    ifstream cin ("elmaj.in");
    ofstream cout ("elmaj.out");
    int x , n;
    cin >> n;
    for(int i=0;i < n;i++){
        cin >>x ;
        frecv[x]++;
    }
    for(auto h : frecv){
        if(h.second >= n / 2){
            cout << h.first << " " << h.second;
            return 0;
        }
    }
    return 0;
}