日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時間:2023/12/10 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 1150A】Stock Arbitraging (贪心,水题) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題干:

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題出背包??)寫完發(fā)現(xiàn)是個完全背包,所以也是可以貪心的,想了想放到A題還是有些合理的,,再看樣例解釋發(fā)現(xiàn)不對,,比想象中的水多了、、、就寫了、、

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;//設(shè)置初始狀態(tài),dpp[i]代表有i塊錢時可以擁有的最大錢數(shù),因為啥都不買所以擁有的是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 ; }

?

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 1150A】Stock Arbitraging (贪心,水题)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。