Team Olympiad

2023-10-19 02:59
文章标签 team olympiad

本文主要是介绍Team Olympiad,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 一、Team Olympiad
  • 总结


一、Team Olympiad

本题链接:A. Team Olympiad

题目

A. Team Olympiad

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

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 the i-th child is good at programming,
ti = 2, if the i-th child is good at maths,
ti = 3, if the i-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 contains n integers t1, t2, …, tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-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.

Examples
input
7
1 3 1 3 2 1 2
output
2
3 5 2
6 7 4

input
4
2 1 1 2
output
0

本博客给出本题截图
在这里插入图片描述

题意:每个孩子都擅长一个技能,共三个技能:1,2,3;每个孩子都只能在一个队伍中,每个队伍由三个孩子组成,并且这三个孩子需要会不同的技能,问最多能组几个队出来,并写出这些队伍中孩子的编号

AC代码

#include <iostream>
#include <algorithm>using namespace std;const int N = 5010;int a[N];
int p[5][N];
int cnt1, cnt2, cnt3;int main()
{int n;cin >> n;for (int i = 1; i <= n; i ++ ) {cin >> a[i];if (a[i] == 1) p[0][cnt1 ++] = i;else if (a[i] == 2)p[1][cnt2 ++] = i;else if (a[i] == 3)p[2][cnt3 ++] = i;}int t = cnt1;t = min(t, cnt2);t = min(t, cnt3);cout << t << endl;for (int i = 0; i < t; i ++ ){for (int j = 0; j < 3; j ++ ) cout << p[j][i] << ' ';puts("");}return 0;
}

总结

p数组二维不可以开成N / 3

这篇关于Team Olympiad的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/236852

相关文章

CodeForces 490A Team Olympiad

题意: 编号为1、2、3的同学分成一组  问  最多形成多少组  并输出方案 思路: 模拟3个栈暴力 代码: #include<cstdio>#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<map>#include<set>#include<vector>#i

Eclipse使用TFS(Team Foundation Server) 超详细

Eclipse使用TFS 1、什么是TFS2、TFS和Git的区别3、签出代码4、签入代码4.1、签出以进行编辑4.2、修改本地代码4.3、签入挂起的更改4.4、签入 如果不能 签入挂起的更改,则先 签出以进行编辑如果 签入挂起的更改不可选中,则 如下操作 1、什么是TFS Team Foundation Server集中式版本控制系统TFS是一种为Microsoft产品提供源代

借报告Team ID错误谈谈Mac app文件签名与公证

文章目录 目的起因流程熟悉本地证书、认证证书申请在钥匙串中创建要公证app的profile(公证的时候会用到)程序打包后App文件进行app签名压缩打包公证公证变化在WWDC19, 苹果在MacOS 10.14之后引入了公证(Notarization)这一机制来提升安全性. 主要分以下几步新的公证workflow 公证命令 添加票据、盖章,注入认证消息mac dmg 打包认证注意事项参考博客

20140501 Anindilyakwa 题解The Great Team 题解

练习结束之后才发现 这两条其实挺水的。。能力还是太弱  水题都刷不动了的节奏么  555555555555  不能老是这么做这些题了  要补知识啊补知识 Description The language of Australian aborigines anindilyakwa has no numerals. No anindilyakwa c

Aras Innovator-Team(群组)的使用方法

当Aras Innovator在处理权限时,在不使用Team的情况下,系统的权限配置可以满足大部分业务场景,如:常见的按照组织架构,成员和角色分配权限,按照生命周期分配权限等。      如果遇到比较复杂的权限需求,如:对于某一套图文档或者物料,在原有的权限设置基础上,同时需要给对应的项目团队成员分配权限。因项目团队成员的灵活性,权限不仅要求项目成员变化时,对应权限同步变更;同时也需要

POJ 1112 Team Them Up!

http://poj.org/problem?id=1112 题意:一共N个人,给出每个人和其余人是否认识,把所有人分成两组。 要求1)每一个人 属于其中一组。 2)每组必须有人  3)每组内的所有人 必须相互认识(有向边 相互认识 才是认识)  4)两组的人数之差尽可能小 先读入数据,把两两不认识的人 连边, 建图,则同一边连接的两点不能在同一组。建完图后,进行DFS 染色,可以把图 分成

W: 无法下载 http://ppa.launchpad.net/fcitx-team/nightly/ubuntu/dists/jessie/main/binary-amd64/Packages

执行apt-get update时出现以下情况 W: 无法下载 http://ppa.launchpad.net/fcitx-team/nightly/ubuntu/dists/jessie/main/binary-amd64/Packages  404  Not Found 解决办法:将对应的PPA删除掉即可 使用以下命令切换到对应PPA目录: cd /etc/apt/source

Team Foundation Server安装指南

一、    说明 Team Foundation Server(以下简称TFS) 提供源代码管理、工作项跟踪、Team Foundation Build、团队项目门户网站、报告和项目管理功能。TFS还包含一个数据仓库,其中存储来自工作项跟踪、源代码管理、版本和测试工具的数据。 TFS的部署模式分为两种,一是单服务器部署,一是双服务器部署,本文主要就单服务器模式的安装进行说明而不涉及双服务

Software Engineering with Microsoft Visual Studio Team System

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/topmvp - topmvp Software Engineering with Microsoft Visual Studio Team System is written for any software team that is

Visual Studio Team System: Better Software Development for Agile Teams

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/topmvp - topmvp Make the Most of Visual Studio Team System in Real-World Agile Development Visual Studio Team System (