use strict; my $N = ; my @list; for (my $i = 0; $i < $N; $i++) { my $str = ; push(@list, $str); } sort(@list); my $cnt = 0; my $cnt_max = 0; my $res = ""; foreach my $i(@list) { if($i != $res) { if($cnt > $cnt_max) { $cnt_max = $cnt; } $cnt = 0; } $cnt++; $res = $i; } if($cnt_max > @list / 2) { print "NO\n"; } else { print "YES\n"; }