-
Notifications
You must be signed in to change notification settings - Fork 3
/
Team_of_Olympiads.cpp
52 lines (45 loc) · 981 Bytes
/
Team_of_Olympiads.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
#include<bits/stdc++.h>
using namespace std;
void showstack(stack <int> s)
{
while (!s.empty())
{
cout << '\t' << s.top();
s.pop();
}
cout << '\n';
}
int main(){
int n;
cin>>n;
stack<int> pro ;
stack<int> pe;
stack<int> maths;
int temp ;
for(int i=1; i<=n; ++i){
cin>>temp;
switch(temp){
case 1:
pro.push(i);
break ;
case 2:
maths.push(i);
break ;
case 3:
pe.push(i);
break ;
}
}
int pS = pro.size();
int peS = pe.size();
int mS = maths.size();
int minimum = min(pS,peS);
minimum = min(minimum,mS);
cout<<minimum <<endl;
while (minimum--){
cout<<pro.top()<<" "<<maths.top()<<" "<<pe.top()<<endl;
pro.pop();
maths.pop();
pe.pop();
}
}