Cod sursa(job #1075163)
| Utilizator | Data | 8 ianuarie 2014 18:25:27 | |
|---|---|---|---|
| Problema | Elementul majoritar | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <cstdio>
#include <map>
using namespace std;
typedef map<int, int> mop;
int main() {
freopen("elmaj.in", "r", stdin);
freopen("elmaj.out", "w", stdout);
int n, x;
mop v;
scanf("%d", &n);
while (n--) {
scanf("%d", &x);
++v[x];
}
mop::iterator i, j;
for (i = j = v.begin(); i != v.end(); ++i)
if (j->second < i->second)
j = i;
printf("%d %d", j->first, j->second);
return 0;
}
