Created
March 11, 2013 20:19
-
-
Save farnoy/5137380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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