-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2033.cpp
More file actions
75 lines (70 loc) · 1003 Bytes
/
2033.cpp
File metadata and controls
75 lines (70 loc) · 1003 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
//заводит данные
string nm, s;
int a;
string dev[6];
int st[6];
for (int i = 0; i < 6; i++)
{
cin >> nm >> s >> a;
dev[i] = s;
st[i] = a;
}
int mx = 0, ii,b=0,jj,ii2,jj2=0,jj22=0;
for (int i = 0; i < 5; i++)
{
int count = 1;
for (int j = i + 1; j < 6; j++)
{
if (dev[i] == dev[j])
{
count++;
jj2 = j;
}
}
if (count == mx)
{
ii2 = i;
jj22 = jj2;
b++;
}
if (count > mx)
{
ii = i;
jj = jj2;
mx = count;
b = 0;
}
}
jj2 = jj22;
if ((mx != 1) && (b == 0))
{
cout << dev[ii];
return 0;
}
if ((mx == 1)||(b==2)||((mx==3)&&(b==1)))
{
int mn = 1000001, h;
for (int i = 0; i < 6; i++)
{
if (st[i] < mn)
{
mn = st[i];
h = i;
}
}
cout << dev[h];
}
else
{
if (min(st[ii], st[jj]) < min(st[ii2], st[jj2]))
cout << dev[ii];
else
cout << dev[ii2];
}
}