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.

****************************************************************************************************************************************************

题意:给你3N个数,要你组成N只team,每一只team3人 :D

每一只team的值为3人的中间值。求出每一只对的总值。

解题思路:先sort一下。可以得到 a1, a2, a3 ~~~~ aN aN+1 ~~~~ a2N a2N+1 ~~~~~a3N;

要求和最大, 所以中间那个要最大,a1, a3N, a3N-1 组成一组

很容易就可以知道贪心的策略了。

****************************************************************************************************************************************************

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int maxn = 300000+10;
int a[maxn];
int main()
{
ios::sync_with_stdio(0);
int N;
cin >> N;
for(int i=0;i<3*N;i++) cin >> a[i];
sort(a, a+3*N);
LL ans = 0;
int j=3*N - 2;
for(int i=1;i<=N;i++)
{
ans += a[j];
j-=2;
}
cout << ans << endl;
return 0;
}

AtCoder Grand Contest 012 A - AtCoder Group Contest(贪心)的更多相关文章

  1. AtCoder Grand Contest 012

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

  2. AtCoder Grand Contest 012 A

    A - AtCoder Group Contest Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statem ...

  3. AtCoder Grand Contest 011

    AtCoder Grand Contest 011 upd:这篇咕了好久,前面几题是三周以前写的... AtCoder Grand Contest 011 A - Airport Bus 翻译 有\( ...

  4. AtCoder Grand Contest 031 简要题解

    AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\). ...

  5. AtCoder Grand Contest 010

    AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题 ...

  6. AtCoder Grand Contest 009

    AtCoder Grand Contest 009 A - Multiple Array 翻译 见洛谷 题解 从后往前考虑. #include<iostream> #include< ...

  7. AtCoder Grand Contest 008

    AtCoder Grand Contest 008 A - Simple Calculator 翻译 有一个计算器,上面有一个显示按钮和两个其他的按钮.初始时,计算器上显示的数字是\(x\),现在想把 ...

  8. AtCoder Grand Contest 007

    AtCoder Grand Contest 007 A - Shik and Stone 翻译 见洛谷 题解 傻逼玩意 #include<cstdio> int n,m,tot;char ...

  9. AtCoder Grand Contest 006

    AtCoder Grand Contest 006 吐槽 这套题要改个名字,叫神仙结论题大赛 A - Prefix and Suffix 翻译 给定两个串,求满足前缀是\(S\),后缀是\(T\),并 ...

随机推荐

  1. 【ABAP系列】SAP ABAP 总结常用术语简称解析

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 总结常用术语简 ...

  2. 关于this、Echarts中的data

    this是指当前对象 移除class的jQuery代码:$('ur.nav li:eq(0)').removeClass('active') 添加class的jQuery代码:$('ur.nav li ...

  3. C# InterLock保证数据一致性

        ; i < ; i++)             {                 c.Increment();                 c.Decrement();      ...

  4. Netty基础-BIO/NIO/AIO

    同步阻塞IO(BIO): 我们熟知的Socket编程就是BIO,每个请求对应一个线程去处理.一个socket连接一个处理线程(这个线程负责这个Socket连接的一系列数据传输操作).阻塞的原因在于:操 ...

  5. mybatis小总结

    mybatis是一个持久层的框架,是一个不完全的orm框架.sql语句需要程序员自己去编写,但是mybatis也有映射(输入参数映射,输出结果映射) mybatis入门门槛不高,学习成本低,让程序员把 ...

  6. java排序算法概述

    一.概述 1.排序也称排序算法(Sort Algorithm),排序是将一组数据,依指定的顺序进行排列的过程. 2.排序的分类: 1) 内部排序: 指将需要处理的所有数据都加载到内部存储器中进行排序. ...

  7. 常见前端面试题CSS部分

    1.盒模型 IE 盒子模型:IE的width部分包含了 border 和 pading; 标准 W3C 盒子模型: width/height+border+padding+margin; 2.清除浮动 ...

  8. elasticsearch 深入 —— 近似匹配

    近似匹配 使用 TF/IDF 的标准全文检索将文档或者文档中的字段作一大袋的词语处理. match 查询可以告知我们这大袋子中是否包含查询的词条,但却无法告知词语之间的关系. 思考下面这几个句子的不同 ...

  9. linux性能分析工具Vmstat

  10. CentOS7.6系统安装zabbix3.4.8客户端

    一.     准备安装包 将本地的zabbix-3.4.8软件包上传至服务器, 二.     安装依赖包 安装依赖包:yum install gcc* pcre* psmisc -y 三.     安 ...