Team Olympiad
来源:互联网 发布:h5和java后端怎么交互 编辑:程序博客网 时间:2024/04/29 11:19
Description
The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti:
- ti = 1, if thei-th child is good at programming,
- ti = 2, if thei-th child is good at maths,
- ti = 3, if thei-th child is good at PE
Each child happens to be good at exactly one of these three subjects.
The Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.
What is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?
Input
The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line containsn integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of thei-th child.
Output
In the first line output integer w — the largest possible number of teams.
Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.
If no teams can be compiled, print the only line with value w equal to 0.
Sample Input
71 3 1 3 2 1 2
23 5 26 7 4
42 1 1 2
0
#include<cstdio>#include<iostream>using namespace std;int num1[5010],num2[5010],num3[5010];int main(){ int n,i,t,sum,one,two,three,zuixiao; while(cin>>n){ one=two=three=sum=0; for(i=1;i<=n;i++){ cin>>t; if(t==1){ num1[one]=i; one++; } else if(t==2){ num2[two]=i; two++; } else if(t==3){ num3[three]=i; three++; } } zuixiao=min(one,min(two,three)); cout<<zuixiao<<endl; for(i=0;i<zuixiao;i++){ cout<<num1[i]<<" "<<num2[i]<<" "<<num3[i]<<endl; } } return 0;}
- Team Olympiad
- A. Team Olympiad
- Codeforces Team Olympiad(暴力)
- 【CODEFORCES】 A. Team Olympiad
- CodeForces 490A Team Olympiad
- coderforce 490A - Team Olympiad
- Codeforces #279 A Team Olympiad 瞎搞
- Codeforces 490A Team Olympiad(水)
- Codeforces Round #279 (Div. 2)---A. Team Olympiad (贪心)
- Codeforces Round #279 (Div. 2) A. Team Olympiad
- codeforces—— 490A —— Team Olympiad
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
- Codeforces Round #441 (Div. 1, by Moscow Team Olympiad)
- olympiad
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) ABCD题解
- 初学django2-基于类的视图中获取URL参数
- Android Studio系列教程四--Gradle基础
- 单例的简单实现
- 数据库设置乐观锁--作用
- Android Studio系列教程五--Gradle命令详解与导入第三方包
- Team Olympiad
- 理解CRITICAL_SECTION
- Android Studio系列教程六--Gradle多渠道打包
- 如何更改分享来源和授权页面的友盟社会化组件字段
- struts2 ui标签使用
- linux rename命令批量修改文件名
- Mac上SVN常用命令
- iOS - 加解密(对称,非对称)(AES DES base64这里都有),数字签名,cookie
- linux系统安装mysql