Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define SPREAD_SIZE 97
- struct dat {
- int n;
- int c;
- };
- dat v[SPREAD_SIZE][10005];
- int main(){
- int n, x, i, x_hash, n_cp2;
- int max_nr = -1, max_c = 0;
- int last_index;
- cin>>n;
- n_cp2 = n / 2;
- for(i = 0; i < SPREAD_SIZE; i++) v[i][0].n = 1;
- while(n--){
- cin>>x;
- x_hash = x % SPREAD_SIZE;
- last_index = 0;
- for(i = 1; i <= v[x_hash][0].n; i++){
- if(v[x_hash][i].n == x){
- v[x_hash][i].c ++;
- last_index = i;
- break;
- }
- }
- if(!last_index){
- last_index = v[x_hash][0].n;
- v[x_hash][last_index].n = x;
- v[x_hash][last_index].c = 1;
- v[x_hash][0].n ++;
- }
- if(v[x_hash][last_index].c > max_c){
- max_c = v[x_hash][last_index].c;
- max_nr = v[x_hash][last_index].n;
- }
- if(max_c >= n_cp2) break;
- }
- if(max_c >= n_cp2) {
- cout<<"DA "<<max_nr;
- }
- else {
- cout<<"NU";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement