A - BBQ Easy
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 i, Li 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的更多相关文章
- AGC01 A - BBQ Easy
目录 题目链接 题解 代码 题目链接 AGC01 A - BBQ Easy 题解 贪心 排序之后从大到小,没两组取小的那个 代码 #include<cstdio> #include< ...
- [Agc001A/At1979] BBQ Easy - 贪心
要准备N组食物, 他有2N的食材, 需要两两组成一个食物, 食物的价值是两食材中较小的那个. 问最大总价值是多少 ---------- 考虑到\(ans = (sum - delta)/2\),只需要 ...
- A*G#C001
AGC001 A BBQ Easy 贪心. https://agc001.contest.atcoder.jp/submissions/7856034 B Mysterious Light 很nb这个 ...
- 【AtCoder】AGC001
AGC001 A - BBQ Easy 从第\(2n - 1\)个隔一个加一下加到1即可 #include <bits/stdc++.h> #define fi first #define ...
- 【AGC板刷记录】
这个帖子,是在自己学知识点累了的时候就看看\(AGC\)的题目来休息. 而且白天上课可以做( AGC-001 \(A\ BBQ Easy\) 考虑从小到大排,相邻两个取为一对. BBQ Easy #i ...
- 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优
libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...
- Struts2 easy UI插件
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- Easy UI常用插件使用
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- UVA-11991 Easy Problem from Rujia Liu?
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...
随机推荐
- DOS使用笔记
DOS下cd命令: cd .. 上一级目录: g: 指定当期目录到G盘,而cd g:是没有效果的: 如图: 在安装Windows服务的过程中,如果installutil为64位版本,那么编译生成项目的 ...
- Centos7 中Nginx的安装与配置
安装与配置 1.安装nginx yum intsall nginxsudo systemctl start nginx 启动服务sudo firewall-cmd --permanent --zone ...
- 【HTML/XML 4】实例分析HTML和XML的不同
导读:上回书说到,XML和HTML有着各自的不同点,综合表现在:1,HTML只是Web显示数据的通用方法,而XML提供了直接处理Web数据的通用方法.2,HTML着重描述Web页面的显示格式,而XML ...
- NYOJ760-See LCS again,有技巧的暴力!
See LCS again 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 There are A, B two sequences, the number of ele ...
- LeetCode:不同路径&不同路径II
不同路径一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为“Finish”). 问 ...
- firefox自动化测试的常用插件
1.firebug 2.firepath 3.firefinder 5.WebDriver Element Locator 提供多种语言的xpath路径
- Cmder使用总结
windows cmd 使用不方便之处: 1.窗口size不能便捷缩放 2.复制文本,不能直接用鼠标拷贝,还需要多一道菜单操作:而且,还只能块状拷贝,而不是按行字符,极其不便 3.不支持多Tab页,多 ...
- JavaScript高级程序设计重点(一)
1.一个完整的 JavaScript 实现应该由下列三 个不同的部分组成 核心(ECMAScript) 文档对象模型(DOM) 浏览器对象模型(BOM) 2.Undefined 类型只有一 ...
- 【c++】多重继承与虚继承
派生类的构造函数初始化列表将实参分别传递给每个直接基类,其中基类的构造顺序与派生列表中基类的出现顺序保持一致,而与派生类构造函数初始化列表中基类的顺序无关. 类型转换与多个基类 编译器不会在派生类向基 ...
- protobuf 之 MessageLite 接口摘录
class LIBPROTOBUF_EXPORT MessageLite { public: inline MessageLite() {} virtual ~MessageLite(); // Ba ...