Kattis Problem - Popular Vote
原题地址
题目类型:简单题
题意
有 n 个候选人,给出每个人获得的投票数,判断谁能获胜。
分析
先对其进行排序,如果票数最多的和第二多的票数一样则说明没有获胜者,如果最多的票数的 2 倍大于总票数则是 Majority winner 否则是 Minority winner。
代码
public static void solve() throws IOException {
int n = nextInt();
Pair[] a = new Pair[n + 1];
int sum =