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 = @list[0]; foreach my $i(@list) { if($i != $res) { $cnt = 0; } $cnt++; $res = $i; if($cnt > $cnt_max) { $cnt_max = $cnt; } } if($cnt_max > @list / 2) { print "NO\n"; } else { print "YES\n"; }