www.ecosway.com-- Problem A
来源:互联网 发布:知乎 低价服务器 编辑:程序博客网 时间:2024/04/28 07:32
Problem A
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 352 Accepted Submission(s): 63
Total Submission(s): 352 Accepted Submission(s): 63
Problem Description
Li Lei has many pearls of N different color. The number of each color is limited. Han Mei is Li Lei’s girl friend.
Since Han Mei’s birthday is coming, Li Lei wants to give Han Mei his present for her birthday. Finally, Li Lei decides to make a chain for his lovely girl friend with his beautiful pearls. He wants to make the chain more beautiful, so the number of the continuous pearls with same color is limited.
Now, Li Lei wants to know how long his chain will be. He will always make the chain as long as possible. Pay attention that the shape of a chain is a line but not a circle here.
Since Han Mei’s birthday is coming, Li Lei wants to give Han Mei his present for her birthday. Finally, Li Lei decides to make a chain for his lovely girl friend with his beautiful pearls. He wants to make the chain more beautiful, so the number of the continuous pearls with same color is limited.
Now, Li Lei wants to know how long his chain will be. He will always make the chain as long as possible. Pay attention that the shape of a chain is a line but not a circle here.
Input
The first line is an integer N. It means that Li Lei has many pearls of N different color.
The next line contains N integers A(0),A(1)……A(N-1). It means that Li Lei has A(i) pearls of the i-th color.
The third line contains N integers B(0),B(1)……B(N-1). It means that in the chain, there will be no more than B(i) continuous pearls of the i-th color.
You can assume that A(i) is not smaller than B(i).
All integers in the input is positive and no larger than 100000.
The next line contains N integers A(0),A(1)……A(N-1). It means that Li Lei has A(i) pearls of the i-th color.
The third line contains N integers B(0),B(1)……B(N-1). It means that in the chain, there will be no more than B(i) continuous pearls of the i-th color.
You can assume that A(i) is not smaller than B(i).
All integers in the input is positive and no larger than 100000.
Output
There is one integer in a line for each test case, representing the length of the chain.
SampleInput
31 1 1001 1 131 1 1001 1 2
SampleOutput
58
题意:
三组数据
第一行 几个不同的珍珠
第二行 不同珍珠的个数
第三行 同一种珍珠对应能相连的最大个数
求最大能连几个珍珠
思路:先按照数目从小到大进行排序 前n-1个一定放完 然后最后一个不同的珍珠在进行判断是否放入
代码:
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;const int INF=1000005;struct Zhenzhu{__int64 num;__int64 zhi;};Zhenzhu zhenzhu[INF];bool cmp(Zhenzhu x,Zhenzhu y){return x.num<y.num;}int main(){int n;while(cin>>n){for(int i=0;i<n;i++){scanf("%I64d",&zhenzhu[i].num);}for(int i=0;i<n;i++){scanf("%I64d",&zhenzhu[i].zhi);}sort(zhenzhu,zhenzhu+n,cmp);__int64 num=n-1;__int64 total=0;for(int i=0;i<num;i++){total+=zhenzhu[i].num;}if((total+1)*zhenzhu[num].zhi>=zhenzhu[num].num){total+=zhenzhu[num].num;} else {total+=(total+1)*zhenzhu[num].zhi; }cout<<total<<endl;}return 0;}
- www.ecosway.com-- Problem A
- www.vegetable_Birds.com-- Problem A
- apache www.a.com 配置
- http://www.javaeye.com/wiki/problem/51232
- http://www.fishc.com/a/book/
- http://codeforces.com/problemset/problem/4/A
- http://codeforces.com/contest/6/problem/A
- http://codeforces.com/contest/7/problem/A
- http://codeforces.com/contest/1/problem/A
- http://codeforces.com/problemset/problem/1/A
- http://codeforces.com/problemset/problem/228/A
- http://codeforces.com/problemset/problem/236/A
- com">www
- How to Outline a Paper [cited from www.ehow.com]
- A nice innovative gift site: http://www.patent-cn.com
- ping百度的时候出现ping www.a.shifen.com
- please get a license from www.texturepacker.com
- Air Ports&&http://www.lightoj.com/volume_showproblem.php?problem=1059
- oracle 函数
- 触须测试程序
- ubuntu android 真机调试配置
- 【Android游戏开发之四】基础的Android 游戏框架(一个游戏角色在屏幕行走的demo)
- linux下的时间相关函数以及如何统计程序运行时间
- www.ecosway.com-- Problem A
- parse命令行的函数简介:getopt和getopt_long (x264中用到了这两个函数)
- 十个经过验证的可用性技巧
- Oracle中5个核心Sql语句的基本构造:Select、Insert、Update、Delete和Merge
- OI 用 Emacs 配置文件
- QT----电子时钟
- android绘制view的过程(自定义view一)
- 2010年机器视觉试题及答案(山东大学控制科学与工程学院)
- OSG+VS2010+windowsxp安装和编译