Skip to content

Instantly share code, notes, and snippets.

@farnoy
Created March 11, 2013 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farnoy/5137380 to your computer and use it in GitHub Desktop.
Save farnoy/5137380 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
const int m = 1001;
int main() {
ios_base::sync_with_stdio(0);//tu wklej te linie
int n;
cin >> n;
int* tab = new int[n];
for (int i = 0; i < m; i++) tab[i] = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
tab[a] += 1;
}
//for (int i = 0; i < m; i++) cout << tab[i] << " ";
//cout << endl;
int max=tab[0], ind=0, prev=0;
bool same = true;
for (int i = 1; i < m; i++) {
if (tab[i] > 0) {
if (prev > 0) {
if (tab[i] != prev)
same = false;
} else {
prev = tab[i];
}
}
if (tab[i] > max) {
max = tab[i];
ind = i;
}
}
//cout << "max=" << max << ";ind=" << ind << endl;
if (same) {
cout << "NIE MA" << endl;
} else {
cout << ind << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment