-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·54 lines (45 loc) · 1000 Bytes
/
Copy pathsol.cpp
File metadata and controls
executable file
·54 lines (45 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
vector<int> V(n + 1);
int maxi = -1;
int maxi_count = 0;
int maxi_i = 0;
int total = 0;
for (int i = 1; i <= n; ++i)
{
cin >> V[i];
total += V[i];
if (V[i] > maxi)
{
maxi = V[i];
maxi_i = i;
maxi_count = 0;
}
if (V[i] == maxi)
{
maxi_count += 1;
}
}
if (maxi_count != 1)
{
cout << "no winner" << endl;
}
else
{
double factor = (double)V[maxi_i] / (double)total;
if (factor > 0.5)
cout << "majority winner " << maxi_i << endl;
else
cout << "minority winner " << maxi_i << endl;
}
}
return 0;
}