Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Migratory Birds
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int n, tmp = -1, ats = -1, mxNum = -1;
- cin >> n; //Number of birds
- vector<int> tip(n);
- for(int tip_i = 0; tip_i < n; tip_i++)
- {
- cin >> tip[tip_i];
- if(tip[tip_i] > mxNum)
- {
- mxNum = tip[tip_i];
- }
- }
- vector<int> cnt(mxNum,0);
- for(int i = 0; i < tip.size(); i++)
- {
- cnt[tip[i]]++;
- }
- for(int i = 0; i <= mxNum; i++)
- {
- if(cnt[i] > tmp){
- tmp = cnt[i];
- ats = i;
- }
- }
- cout << ats << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment