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 ...
随机推荐
- Seesion和Cookie详解2
转载来自: https://www.toutiao.com/a6693986851193094664/?tt_from=weixin&utm_campaign=client_share& ...
- java验证码图片
package com.su.servlet; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; impor ...
- Hadoop每日一讨论整理版
这是我在几个QQ群发起的Hadoop每日一讨论小活动,每天中午2点左右发出一个关于Hadoop的知识片段,在此做一个整理. [每日一讨论]之计算框架(2013-5-21) 就计算框架而言,Hadoop ...
- XHTML中button加入超链接以及使插入图片与屏幕一样大
1.button加入超链接 (1)假设是在本页跳转到新页面.用 <span style="font-size:18px;"><input type="b ...
- Spring中的AOP(学习笔记)
是什么AOP及实现方式 AOP的基本概念 Schema-base AOP Spring AOP API AspectJ
- js modify local file
https://stackoverflow.com/questions/4561157/is-it-possible-to-modify-a-html-file-from-which-the-scri ...
- 编写自定义PE结构的程序(如何手写一个PE,高级编译器都是编译好的PE头部,例如MASM,TASM等,NASM,FASM是低级编译器.可以自定义结构)
正在学PE结构...感谢个位大哥的文章和资料...这里先说声谢谢 一般高级编译器都是编译好的PE头部,例如MASM,TASM等一直都说NASM,FASM是低级编译器.可以自定义结构但是苦于无人发布相关 ...
- mysql表分区 partition
表分区 partition 当一张表的数据非常多的时候,比如单个.myd文件都达到10G, 这时,必然读取起来效率降低. 可不可以把表的数据分开在几张表上? 1: 从业务角度可以解决.. (分表,水平 ...
- Intel® Media Server Studio Support
复制自网址:https://software.intel.com/en-us/intel-media-server-studio-support/code-samples Code Samples M ...
- LA-4726 (斜率优化+单调队列)
题意: 给定一个01序列,选一个长度至少为L 的连续子序列使其平均值最大;输出这个子序列的起点和终点;如果有多个答案,输出长度最小的,还有多个就输出第一个编号最小的; 思路: 用sum[i]表示[1, ...