Score : 200 points

Problem Statement

Snuke is having a barbeque party.

At the party, he will make N servings of Skewer Meal.

Example of a serving of Skewer Meal

He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is Li. Also, he has an infinite supply of ingredients.

To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers. Let the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.

What is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?

Constraints

  • 1≦N≦100
  • 1≦Li≦100
  • For each iLi is an integer.

Input

The input is given from Standard Input in the following format:

N
L1 L2 L2N

Output

Print the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.


Sample Input 1

2
1 3 1 2

Sample Output 1

3

If he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of3.


Sample Input 2

5
100 1 2 3 14 15 58 58 58 29

Sample Output 2

135

挺有意思的题目,排个序就ok了

/* ***********************************************
Author :guanjun
Created Time :2016/7/16 23:23:01
File Name :agc1a.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int a[];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
while(cin>>n){
for(int i=;i<=n*;i++)cin>>a[i];
sort(a+,a++*n);
int sum=;
for(int i=*n;i>=;i-=){
sum+=a[i-];
}
cout<<sum<<endl;
}
return ;
}

A - BBQ Easy的更多相关文章

  1. AGC01 A - BBQ Easy

    目录 题目链接 题解 代码 题目链接 AGC01 A - BBQ Easy 题解 贪心 排序之后从大到小,没两组取小的那个 代码 #include<cstdio> #include< ...

  2. [Agc001A/At1979] BBQ Easy - 贪心

    要准备N组食物, 他有2N的食材, 需要两两组成一个食物, 食物的价值是两食材中较小的那个. 问最大总价值是多少 ---------- 考虑到\(ans = (sum - delta)/2\),只需要 ...

  3. A*G#C001

    AGC001 A BBQ Easy 贪心. https://agc001.contest.atcoder.jp/submissions/7856034 B Mysterious Light 很nb这个 ...

  4. 【AtCoder】AGC001

    AGC001 A - BBQ Easy 从第\(2n - 1\)个隔一个加一下加到1即可 #include <bits/stdc++.h> #define fi first #define ...

  5. 【AGC板刷记录】

    这个帖子,是在自己学知识点累了的时候就看看\(AGC\)的题目来休息. 而且白天上课可以做( AGC-001 \(A\ BBQ Easy\) 考虑从小到大排,相邻两个取为一对. BBQ Easy #i ...

  6. 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优

    libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...

  7. Struts2 easy UI插件

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  8. Easy UI常用插件使用

    一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...

  9. UVA-11991 Easy Problem from Rujia Liu?

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

随机推荐

  1. 3.3.4 使用 awk 重新编排字段

    awk 本身所提供的功能完备,已经是一个很好用的程序语言了.以后会好好地介绍该语言的精髓.虽然 awk 能做的事很多,但它主要的设计是要在 Shell脚本中发挥所长:做一些简单的文本处理,例如取出字段 ...

  2. DEVExpress中BarItem的使用2

    没有验证LookUpEdit与ComBox的区别. 没有验证ZoomTrackBarControl的使用方法. SparkLine看着也蛮有趣,需要绑定数据源控件的均没有验证. 前一节介绍的BarIt ...

  3. zoj 1295 Reverse Text

    Reverse Text Time Limit: 2 Seconds      Memory Limit: 65536 KB In most languages, text is written fr ...

  4. 【贪心】codeforces B. Heidi and Library (medium)

    http://codeforces.com/contest/802/problem/B [题意] 有一个图书馆,刚开始没有书,最多可容纳k本书:有n天,每天会有人借一本书,当天归还:如果图书馆有这个本 ...

  5. 运行hadoop自带的计算圆周率异常

    运行hadoop2 自带的圆周率计算方法时,报错,找了半天,原来是在配置hadoop临时目录时,没有给权限,找到配置的hadoop临时目录文件夹,修改权限即可 Application applicat ...

  6. Codeforces Round #292 (Div. 2) D. Drazil and Tiles [拓扑排序 dfs]

    传送门 D. Drazil and Tiles time limit per test 2 seconds memory limit per test 256 megabytes Drazil cre ...

  7. Django的form,model自定制

    一.Form组件原理: django框架提供了一个form类,来处理web开发中的表单相关事项.众所周知,form最常做的是对用户输入的内容进行验证,为此django的forms类提供了全面的内容验证 ...

  8. 代码svn下载到本地后,关于数据库问题

    代码svn下载到本地后,关于数据库问题 1.那我本地还用搭建相应的数据库么?答案:当然不用啦,本地系统里已经配置好了数据库的网络地址了,端口号,密码啥的.即使你代码运行在本地,依然可以将数据传输到服务 ...

  9. 学习MarkDown--初体验

    学习MarkDownPad 突然兴趣来了,在博客园里面也有Markdown的格式,昨天晚上安装了MarkDownPad pro这个是免费的,但是有些功能不支持.本来想破解的,百度了很多方法感觉不靠谱, ...

  10. HDU3926Hand in Hand(搜索 或 并查集)

    Problem Description In order to get rid of Conan, Kaitou KID disguises himself as a teacher in the k ...