AtCoder Grand Contest 012 A
A - AtCoder Group Contest
Time limit : 2sec / Memory limit : 256MB
Score : 300 points
Problem Statement
There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer ai. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.
The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.
Find the maximum possible sum of the strengths of N teams.
Constraints
- 1≤N≤105
- 1≤ai≤109
- ai are integers.
Input
Input is given from Standard Input in the following format:
N
a1 a2 … a3N
Output
Print the answer.
Sample Input 1
2
5 2 8 5 1 5
Sample Output 1
10
The following is one formation of teams that maximizes the sum of the strengths of teams:
- Team 1: consists of the first, fourth and fifth participants.
- Team 2: consists of the second, third and sixth participants.
Sample Input 2
10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 2
10000000000
The sum of the strengths can be quite large.
题意:给3*N个数,3个一组,我们取每个组第二大的数出来相加,问最大能够是多少~
解法:排序,取2,4,6,8..就行
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum=;
ll a[*];
bool cmd(ll x,ll y)
{
return x>y;
}
int main()
{
int n;
cin>>n;
for(int i=;i<=*n;i++)
{
cin>>a[i];
}
int i=;
sort(a+,a++*n,cmd);
while((n)--)
{
sum+=a[i];
//cout<<a[i]<<endl;
i+=;
}
cout<<sum<<endl;
return ;
}
AtCoder Grand Contest 012 A的更多相关文章
- AtCoder Grand Contest 012
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...
- AtCoder Grand Contest 012 A - AtCoder Group Contest(贪心)
Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are 3N participa ...
- AtCoder Grand Contest 012 C:Tautonym Puzzle
题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_c 题目翻译 如果一个字符串是好的,那么这个字符串的前半部分和后半部分肯定一模一样.比如\(a ...
- AtCoder Grand Contest 012 D:Colorful Balls
题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_d 题目翻译 给你一排一共\(N\)个球,每个球有一个颜色\(c_i\)和一个重量\(w_i\ ...
- AtCoder Grand Contest 012 B - Splatter Painting(dp)
Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting v ...
- AtCoder Grand Contest 012 B Splatter Painting (反向处理 + 记忆化)
题目链接 agc012 Problem B 题意 给定一个$n$个点$m$条边的无向图,现在有$q$个操作.对距离$v$不超过$d$的所有点染色,颜色编号为$c$. 求每个点最后的颜色状态. 倒过 ...
- AtCoder Grand Contest 012 B
B - Splatter Painting Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement ...
- AtCoder Grand Contest 012 D Colorful Balls
题意: 有N个球排成一行,第i个球颜色为ci, 权为wi, 如果两个同色球权值和 <= X 则它们可以交换: 如果两个异色球权值和 <= Y 则它们可以交换:不限制交换次数,求能到达的颜色 ...
- AtCoder Grand Contest 012 B Splatter Painting(记忆化搜索)
题意: 给一个包含N个顶点,M条边,无自环和重边的简单无向图,初始每个点颜色都为0,每条边的长度为1,连接着ai,bi两个节点.经过若干个操作, 每次将与某个点vi距离不超过di的所有点染成某种颜色c ...
随机推荐
- linux getopt函数详解
getopt(分析命令行参数) 表头文件 #include<unistd.h> 定义函数 int getopt(int argc,char * const argv[ ],const ...
- spring test---測试SpringMvc初识
如今越来越多人使用SpringMvc来开发系统,在开发中可定须要对后台url地址请求測试,而且返回预期的结果! Spring提供的測试类MockMvc来进行url地址请求測试,使用方方式: packa ...
- jws webservice code
1.服务器端建立 1.1.创建接口 [java] view plaincopy @WebService public interface IWebService { int add(int ...
- 附录: mysql show processlist中的State的意义
附录: mysql show processlist中的State的意义 Checking table 正在检查数据表(这是自动的). Closing tables 正在将表中修改的数据刷新到磁盘中, ...
- 代码块、继承、this、super、final(java基础知识八)
1.代码块的概述和分类 * A:代码块概述 * 在Java中,使用{}括起来的代码被称为代码块.* B:代码块分类 * 根据其位置和声明的不同,可以分为局部代码块,构造代码块,静态代码块,同步代码块( ...
- loadrunner性能测试步骤
性能测试过程分为4个阶段:设计.构建.执行.分析/诊断/调节具体的工作流程如下图 设计 > 构建 > 执行 > 分析/诊断/调节 收集要求 设置测试环境 基准测试 诊断瓶颈 设计测试 ...
- assign.py
#链式赋值 m=n=[1,2,3] m[0]=2 print(m,n) #m,n都改变了 x=y='xxx' y='yyy' print(x,y) #只有y 改变 #序列解包 x,y,z=1,2,3 ...
- [POI 2007] 办公楼
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1098 [算法] 显然 , 答案为补图的连通分量个数 用链表优化BFS , 时间复杂度 ...
- MYSQL数据库学习----MYSQL函数
MYSQL函数分为几种 数学函数 字符串函数 日期和时间函数 条件判断函数 系统信息函数 加密函数 格式化函数 一:数学函数 主要使用的几个数学函数 1 ABS()----绝对值函数 eg. SELE ...
- Bootstrap-CL:按钮下拉菜单
ylbtech-Bootstrap-CL:按钮下拉菜单 1.返回顶部 1. Bootstrap 按钮下拉菜单 本章将讲解如何使用 Bootstrap class 向按钮添加下拉菜单.如需向按钮添加下拉 ...