-
Notifications
You must be signed in to change notification settings - Fork 0
/
490A_team-olympiad.cpp
55 lines (45 loc) · 1.06 KB
/
490A_team-olympiad.cpp
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
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define min3(a, b, c) std::min(std::min(a, b), c)
#define max3(a, b, c) std::max(std::max(a, b), c)
int32_t main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int students_number;
std::cin >> students_number;
int mathematicians_number = 0;
int programmers_number = 0;
int sportsmen_number = 0;
std::vector <int> programmers;
std::vector <int> mathematicians;
std::vector <int> sportsmen;
for (int i = 1; i <= students_number; ++i)
{
int student;
std::cin >> student;
if (student == 1)
{
++programmers_number;
programmers.push_back(i);
}
else if (student == 2)
{
++mathematicians_number;
mathematicians.push_back(i);
}
else
{
++sportsmen_number;
sportsmen.push_back(i);
}
}
int result = min3(programmers_number, mathematicians_number, sportsmen_number);
std::cout << result << '\n';
for (int i = 0; i < result; ++i)
{
std::cout << programmers[i] << ' ' << mathematicians[i] << ' ' << sportsmen[i] << '\n';
}
return 0;
}