【CodeForces - 1150A】Stock Arbitraging (贪心,水题)

题干:

Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!

In the morning, there are nn opportunities to buy shares. The ii-th of them allows to buy as many shares as you want, each at the price of sisi bourles.

In the evening, there are mm opportunities to sell shares. The ii-th of them allows to sell as many shares as you want, each at the price of bibi bourles. You can't sell more shares than you have.

It's morning now and you possess rr bourles and no shares.

What is the maximum number of bourles you can hold after the evening?

Input

The first line of the input contains three integers n,m,rn,m,r (1≤n≤301≤n≤30, 1≤m≤301≤m≤30, 1≤r≤10001≤r≤1000) — the number of ways to buy the shares on the market, the number of ways to sell the shares on the market, and the number of bourles you hold now.

The next line contains nn integers s1,s2,…,sns1,s2,…,sn (1≤si≤10001≤si≤1000); sisi indicates the opportunity to buy shares at the price of sisi bourles.

The following line contains mm integers b1,b2,…,bmb1,b2,…,bm (1≤bi≤10001≤bi≤1000); bibi indicates the opportunity to sell shares at the price of bibi bourles.

Output

Output a single integer — the maximum number of bourles you can hold after the evening.

Examples

Input

3 4 11
4 2 5
4 4 5 4

Output

26

Input

2 2 50
5 7
4 2

Output

50

Note

In the first example test, you have 1111 bourles in the morning. It's optimal to buy 55shares of a stock at the price of 22 bourles in the morning, and then to sell all of them at the price of 55 bourles in the evening. It's easy to verify that you'll have 2626 bourles after the evening.

In the second example test, it's optimal not to take any action.

解题报告:

简单的贪心,,刚开始读错题了还以为是个背包。。(cfA题出背包??)写完发现是个完全背包,所以也是可以贪心的,想了想放到A题还是有些合理的,,再看样例解释发现不对,,比想象中的水多了、、、就写了、、

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
int dp[MAX],dpp[MAX],n,m,r,a[MAX],b[MAX];
int main()
{cin>>n>>m>>r;for(int i = 1; i<=n; i++) cin>>a[i];for(int i = 1; i<=m; i++) cin>>b[i];int minn = *min_element(a+1,a+n+1);int maxx = *max_element(b+1,b+m+1);int ci = r/minn;printf("%d\n",max(r,r + (maxx-minn)*ci));//	for(int i = 0; i<=r; i++) dpp[i] = r;//设置初始状态,dpp[i]代表有i块钱时可以拥有的最大钱数,因为啥都不买所以拥有的是r
//	for(int i = 1; i<=min(n,m); i++) {
//		for(int j = a[i]; j<=r; j++) {
//			if(dp[j-a[i]] + b[i]-a[i] > dp[j]) {
//				dp[j] = dp[j-a[i]] + b[i]-a[i];
//				dpp[j] = dpp[j-a[i]] + b[i]-a[i];
//			}
//		}
//	}
//	printf("%d\n",dpp[r]);return 0 ;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440384.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

html以图像中心定位,在HTML图像上水平和垂直居中文本(绝对定位)

Michael Roach0htmlcssflexbox鉴于以下设计元素,我试图在html中包含图像,以便可以使用css过渡(悬停效果)操纵不透明度.这里的主要缺点是我使用手动垂直居中(绝对/顶部:4​​0%),这在缩小浏览器时变得明显.在使用绝对定位时,是否可以使用flexbox或table进行垂直居中&#xff1f;…

*【CodeForces - 1150D】Three Religions(dp,预处理,思维)

题干&#xff1a; During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now…

基于android公交车线路查询论文文献,本科毕业论文---基于android的手机公交线路查询系统.doc...

毕 业 设 计( 论 文 )题目手机公交线路查询系统作者学院专业学号指导教师摘 要关键词&#xff1b;AbstractWith the level of people’s life improving,going out by bus become a necessary part of daily life.And the traffic line to destination should be known everyti…

【POJ - 3159】Candies (差分约束,卡SPFA)

题干&#xff1a; 在幼儿园的时候&#xff0c;Flymouse是班上的班长。有时班主任会给班上的孩子们带来一大袋糖果&#xff0c;让他们分发。所有的孩子都非常喜欢糖果&#xff0c;经常比较他们和别人买的糖果的数量。一个孩子A可以有这样的想法&#xff0c;尽管可能是另一个孩子…

计算机英语第六单元,计算机专业英语第六版第十单元课后汉译英,We do use other forms....这个do...

同样的 &#xff0c;多线程也存在许多缺点 &#xff0c;在考虑多线程时需要进行充分的考虑。多线程的主要缺点包括&#xff1a;Similarly, multi thread also has many shortcomings, in the consideration of the need for the full consideration of multiple threads. The m…

1.Hello,Python

本文为Kaggle Learn的Python课程的中文翻译&#xff0c;原文链接为&#xff1a;https://www.kaggle.com/colinmorris/hello-python 欢迎来到Kaggle Learn的Python课程。本课程将介绍在开始使用Python进行数据科学之前需要的基本Python技能。这些课程针对那些具有一些编程经验的…

【POJ - 1273】Drainage Ditches(网络流,最大流,模板)

题干&#xff1a; 现在有m个池塘(从1到m开始编号,1为源点,m为汇点),及n条水渠,给出这n条水渠所连接的点和所能流过的最大流量&#xff0c;求从源点到汇点能流过的最大流量。 Input 输入包括几种情况。 对于每种情况&#xff0c;第一行包含两个空格分隔的整数&#xff0c;N&a…

计算机网络阶段,计算机网络的发展大致可分为四个阶段,目前人类进入了()。 - 问答库...

问题&#xff1a;[单选] 计算机网络的发展大致可分为四个阶段&#xff0c;目前人类进入了()。A . 计算机网络阶段B . 信息高速公路阶段C . 计算机网络互联阶段D . 远程终端联机阶段教育心理学是研究教育情境中学生学习的基本心理规律的科学。王林平时成绩一般&#xff0c;但总想…

2.Functions and Getting Help

Functions and Getting Help 在本课中&#xff0c;我们将讨论函数&#xff1a;调用它们&#xff0c;定义它们&#xff0c;并使用Python的内置文档查找它们。 在某些语言中&#xff0c;定义函数必须要有特定的参数&#xff0c;每个参数都具有特定类型。 Python函数允许更灵活。…

华人科学家量子计算机,华人科学家在美国研发出性能强大的光子计算机,能够与中国的量子计算机一战高下!...

原标题&#xff1a;华人科学家在美国研发出性能强大的光子计算机&#xff0c;能够与中国的量子计算机一战高下&#xff01;在最近的《自然纳米技术》杂志上&#xff0c;一篇来自美国哥伦比亚大学的论文在业界掀起了轩然大波&#xff0c;一位名叫虞南方的物理学助理教授成功率领…

【BZOJ - 1001】狼抓兔子(无向图网络流,最小割,或平面图转对偶图求最短路SPFA)

题干&#xff1a; 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到&#xff0c;但抓兔子还是比较在行的&#xff0c; 而且现在的兔子还比较笨&#xff0c;它们只有两个窝&#xff0c;现在你做为狼王&#xff0c;面对下面这样一个网格的地形&#xff1a; …

3.Booleans and Conditionals

Booleans Python有bool类型数据&#xff0c;有两种取值&#xff1a;True 和 False. [1] x True print(x) print(type(x)) True <class bool> 我们通常从布尔运算符中获取布尔值&#xff0c;而不是直接在我们的代码中放入True或False。 这些是回答yes或no的运算符。…

能利用计算机来模拟某种真实的实验现象,自然现象或社会现象的课件是,《计算机辅助教学》课程复习资料...

考试资料《计算机辅助教学》课程复习资料一、单项选择题1. 教学软件又称为 A 。A.课件 B.多媒体 C.操作系统 D.应用软件2. 继课件之后的第二代教学软件称为 A 。A积件 B.课件 C.网络课件 D.智能型课件3. 建构主义学习理论强调认知主体是 B 。A. 教师 B. 学习者 C. 教务 D. 辅导…

【洛谷 - P3376 】【模板】网络最大流

题干&#xff1a; 如题&#xff0c;给出一个网络图&#xff0c;以及其源点和汇点&#xff0c;求出其网络最大流。 输入输出格式 输入格式&#xff1a; 第一行包含四个正整数N、M、S、T&#xff0c;分别表示点的个数、有向边的个数、源点序号、汇点序号。 接下来M行每行包含…

4.Lists

Lists Python中的列表表示有序的值。 可以使用方括号来定义&#xff0c;变量值之间用逗号隔开。 例如&#xff0c;这是几个素数的列表&#xff1a; [1] primes [2, 3, 5, 7] 我们可以将其他类型的东西放在列表中&#xff1a; [2] planets [Mercury, Venus, Earth, Mars…

怎么用计算机拟合数据,数据拟合的几个应用实例-毕业论文.doc

本科毕业设计(论文)数据拟合的几个使用实例燕 山 大 学年 月本科毕业设计(论文)数据拟合的几个使用实例学 院&#xff1a;专 业&#xff1a;学生姓名&#xff1a;学 号&#xff1a;指导教师&#xff1a;答辩日期&#xff1a;燕山大学毕业设计任务书学院&#xff1a; 系级教学单…

1.UNIX网络编程卷1:源码配置

本节主要介绍UNIX网络编程卷1&#xff08;第三版&#xff09;在Ubuntu16.04的配置问题&#xff0c;并运行一个简单时间获取客户程序。 1.首先下载源文件&#xff0c;链接如下&#xff1a;UNIX Network Programming Source Code 2.将下载好的压缩文件unpv13e.tar.gz解压&#…

【牛客 - 696C】小w的禁忌与小G的长诗(dp 或 推公式容斥)

题干&#xff1a; 链接&#xff1a;https://ac.nowcoder.com/acm/contest/696/C 来源&#xff1a;牛客网 自从上次小w被奶牛踹了之后&#xff0c;就一直对此耿耿于怀。 于是"cow"成为了小w的禁忌&#xff0c;而长得和"cow"很像的"owc"…凡是…

html 地球大气,地球大气层为什么永远不会消失?

地球的大气层是一个很神奇的存在&#xff0c;几十亿年来&#xff0c;它就如同一层厚厚的保护膜&#xff0c;将地球与太空完全阻隔起来&#xff0c;正因为如此&#xff0c;地球上的生命才能够繁衍生息&#xff0c;代代相传。相信很多人都会有这样的疑问&#xff0c;为什么地球上…

5.Loops and List Comprehensions

Loops 循环是一种重复执行某些代码的方法。 [1] planets [Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune] for planet in planets:print(planet, end ) # print all on same line Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune 注意for循环…