HDUOJ---1171
http://acm.hdu.edu.cn/showproblem.php?pid=1171
Big Event in HDU
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18439 Accepted Submission(s): 6457
The splitting is absolutely a big event in HDU! At the same time, it is a trouble thing too. All facilities must go halves. First, all facilities are assessed, and two facilities are thought to be same if they have the same value. It is assumed that there is N (0<N<1000) kinds of facilities (different value, different kinds).
A test case starting with a negative integer terminates input and this test case is not to be processed.
#include<iostream>
#include<cstdlib>
using namespace std;
typedef struct Node
{
int value;
int num;
}node;
int cmp( const void *a, const void *b)
{
return (*(node*)b).value-(*(node*)a).value;
}
int main()
{
int n,i,sum,count,min;
node arr[];
while(cin>>n,n>)
{
for(sum=i=;i<n;i++)
{
cin>>arr[i].value>>arr[i].num;
sum+=arr[i].value*arr[i].num;
}
qsort(arr,n,sizeof(arr[]),cmp);
min=;
for(count=i=;i<n;i++)
{
while(arr[i].num)
{
if(count+arr[i].value<=sum/)
{
count+=arr[i].value;
}
arr[i].num--;
}
if(min<count)
{
min=count;
}
}
cout<<sum-min<<" "<<min<<endl;
}
return ;
}
HDUOJ---1171的更多相关文章
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- 1171. Lost in Space
http://acm.timus.ru/problem.aspx?space=1&num=1171 一天的时间,WA了N遍,居然是因为数组开小了呀,我勒个去!鄙视自己...... 我是从第 1 ...
- 【BZOJ-2892&1171】强袭作战&大sz的游戏 权值线段树+单调队列+标记永久化+DP
2892: 强袭作战 Time Limit: 50 Sec Memory Limit: 512 MBSubmit: 45 Solved: 30[Submit][Status][Discuss] D ...
- HDU 1171 Big Event in HDU 多重背包二进制优化
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171 Big Event in HDU Time Limit: 10000/5000 MS (Jav ...
- hdu(1171)多重背包
hdu(1171) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hdu 01背包汇总(1171+2546+1864+2955。。。
1171 题意比较简单,这道题比较特别的地方是01背包中,每个物体有一个价值有一个重量,比较价值最大,重量受限,这道题是价值受限情况下最大,也就值把01背包中的重量也改成价值. //Problem : ...
- Codevs 1171 潜伏者 2009年NOIP全国联赛提高组
1171 潜伏者 2009年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description [问题描述] R 国和S 国正陷 ...
- [HDOJ 1171] Big Event in HDU 【完全背包】
题目链接:HDOJ - 1171 题目大意 有 n 种物品,每种物品有一个大小和数量.要求将所有的物品分成两部分,使两部分的总大小尽量接近. 题目分析 令 Sum 为所有物品的大小总和.那么就是用给定 ...
随机推荐
- coco游戏android.mk
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := game_shared LOCAL_MODULE_FILENAME ...
- 【ContestHunter】【弱省胡策】【Round5】
反演+FFT+构造+DP 写了这么多tag,其实我一个也不会 A 第一题是反演……数据范围10W,看着就有种要用FFT等神奇算法的感觉……然而蒟蒻并不会推公式,只好写了20+10分的暴力,然而特判30 ...
- Kmeans聚类算法分析(转帖)
原帖地址:http://www.opencvchina.com/thread-749-1-1.html k-means是一种聚类算法,这种算法是依赖于点的邻域来决定哪些点应该分在一个组中. ...
- guess-number-higher-or-lower
// Forward declaration of guess API. // @param num, your guess // @return -1 if my number is lower, ...
- Informatica 常用组件Source Qualifier之七 输入过滤器
通过输入源过滤器,可以降低 PowerCenter 查询的行数.如果在源过滤器中包括字符串 "WHERE" 或较大对象,PowerCenter 将使会话失败. 源限定符转换包括默 ...
- 使用Topshelf 5步创建Windows 服务
使用Topshelf创建Windows 服务简要的介绍了创建Windows服务的另一种方法,老外的一篇文章Create a .NET Windows Service in 5 steps with T ...
- 一行代码轻松实现拖动效果[JQuery]
写JS实现拖动需要一大堆不便维护的代码,实属麻烦,Google了大半天,发现了一个优秀的Jquery插件EasyDrag,只需要一行代码便可轻松在主流浏览器上 实现拖动效果. $(document ...
- [JSP]JSP中include指令和include动作的差别
include指令是编译阶段的指令,即include所包括的文件的内容是编译的时候插入到JSP文件里,JSP引擎在推断JSP页面未被改动,否则视为已被改动. 因为被包括的文件是在编译时才插入的.因此假 ...
- js获取checkbox中所有选中值及input后面所跟的文本
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- C#类似版本号有多个分割符可以产生的排列组合,类似版本号比较
我采用asp.net进行演示 送给有缘人吧,可以获得类似版本号的功能,也可以对比两个版本号,我这里是其他需要用逗号分割的 using System; public partial class _Def ...