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 152 has a strength 2, and a team of three participants of strength 323 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

Copy
2
5 2 8 5 1 5

Sample Output 1

Copy
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

Copy
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

Copy
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的更多相关文章

  1. AtCoder Grand Contest 012

    AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...

  2. AtCoder Grand Contest 012 A - AtCoder Group Contest(贪心)

    Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement There are 3N participa ...

  3. AtCoder Grand Contest 012 C:Tautonym Puzzle

    题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_c 题目翻译 如果一个字符串是好的,那么这个字符串的前半部分和后半部分肯定一模一样.比如\(a ...

  4. AtCoder Grand Contest 012 D:Colorful Balls

    题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_d 题目翻译 给你一排一共\(N\)个球,每个球有一个颜色\(c_i\)和一个重量\(w_i\ ...

  5. AtCoder Grand Contest 012 B - Splatter Painting(dp)

    Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting v ...

  6. AtCoder Grand Contest 012 B Splatter Painting (反向处理 + 记忆化)

    题目链接  agc012 Problem B 题意  给定一个$n$个点$m$条边的无向图,现在有$q$个操作.对距离$v$不超过$d$的所有点染色,颜色编号为$c$. 求每个点最后的颜色状态. 倒过 ...

  7. AtCoder Grand Contest 012 B

    B - Splatter Painting Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement ...

  8. AtCoder Grand Contest 012 D Colorful Balls

    题意: 有N个球排成一行,第i个球颜色为ci, 权为wi, 如果两个同色球权值和 <= X 则它们可以交换: 如果两个异色球权值和 <= Y 则它们可以交换:不限制交换次数,求能到达的颜色 ...

  9. AtCoder Grand Contest 012 B Splatter Painting(记忆化搜索)

    题意: 给一个包含N个顶点,M条边,无自环和重边的简单无向图,初始每个点颜色都为0,每条边的长度为1,连接着ai,bi两个节点.经过若干个操作, 每次将与某个点vi距离不超过di的所有点染成某种颜色c ...

随机推荐

  1. adb问题整理

    1.开启了两个adb,关掉一个,重启eclipse既可 java.io.IOException: 您的主机中的软件中止了一个已建立的连接. at sun.nio.ch.SocketDispatcher ...

  2. rtsp 播放器

    http://blog.csdn.net/niu_gao/article/details/7753672 /********************************************** ...

  3. 应用require.js进行javascript模块化编程小试一例

    长久以来都渴望应用javascript的模块化编程.今日紧迫更甚,岁月蹉跎,已经不能再等了. 拜读阮一峰的有关文章已经好几遍,文章写得真好,简洁流畅,头头是道,自觉有点明白了.但经验告诉我们,一定要亲 ...

  4. 火焰灯menu修改之后,可以实现数遍点击小方块停留在当前页面

    下载地址:http://www.cnblogs.com/RightDear/admin/Files.aspx 调用方式,传入一个参数 首页传入0,关于联盟传入1,产品展示传入2,依此类推 <sc ...

  5. 小程序登录方式切换 不做url跳转

    var filegUP = require('../../utils/getUserPassword.js'); var filemd5 = require('../../utils/md5.min. ...

  6. 【转】【录教程必备】推荐几款屏幕录制工具(可录制GIF)

    我们经常会遇到一些场景,需要你向别人展示一些操作或是效果——例如告诉别人某某软件的配置步骤啊.刚设计出来网站的动画效果怎么样啊.某某电影里面的一个镜头多么经典啊.打得大快人心的NBA绝杀瞬间是怎么回事 ...

  7. em和i , b和Strong 的区别

    这两对标签最大区别就是一个给搜索引擎看的,一个是给用户看的. b标签和strong标签给我们的主观感受都是加粗,但对搜索引擎来说b标签和普通的文字并没有什么区别,而strong标签却是起强调作用的. ...

  8. 序列流、对象操作流、打印流、标准输入输出流、随机访问流、数据输入输出流、Properties(二十二)

    1.序列流 * 1.什么是序列流 * 序列流可以把多个字节输入流整合成一个, 从序列流中读取数据时, 将从被整合的第一个流开始读, 读完一个之后继续读第二个, 以此类推.* 2.使用方式 * 整合两个 ...

  9. 简易五子棋 V1.1.0

    main.cpp #include "fivechess.cpp" int main() { fivechess a; a.RunGame(); getchar(); return ...

  10. linux oracle命令行窗口命令上下翻阅

    1.上传rlwrap-0.37.tar.gz到/stage   cd /stage/ 解压tar xzvf rlwrap-0.37.tar.gz cd rlwrap-0.37 ./configure ...