Codeforces Round #556 (Div. 2) A题

题面很简单,思路就是简单贪心,si数组是贮存购买数组,bi数组是贮存出售数组,题面是给你r的货币,让你通过出售和购买来获取最大价值,第一种算法是通过找出bi数组最大值,和si数组最小值,通过比较来计算最大值,如果bi数组最大值小于了si数组最小值,说明购买无意义,反之只要计算能买多少只si数组的股票,去出售bi数组的最大值换去收益。接下来是代码

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 10010;
int main()
{
 int n, m, r;
 int a[maxn], b[maxn];
 cin >> n >> m >> r;
 for (int i = 0; i < n; i++)
 {
  scanf("%d", &a[i]);
 }
 for (int i = 0; i < m; i++)
 {
  scanf("%d", &b[i]);
 }
 sort(a, a + n);
 sort(b, b + m);
 if (a[0] >= b[m - 1])
 {
  printf("%d\n", r);
 }
 else
 {
  int sum = 0;
  int x = r % a[0];
  sum = x + r / a[0] * b[m - 1];
  cout << sum << endl;
 }
}

转载于:https://www.cnblogs.com/csxaxx/p/10800458.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值