首页 > 其他 > 详细

【题解】 CF734C Anton and Making Potions

时间:2021-08-15 11:40:45      阅读:20      评论:0      收藏:0      [点我收藏+]

题意

要求得到至少 \(n\) 个药剂,可以使用两种魔法,一种能够缩短制药时间,一种能瞬间制药,

给你 \(x\) 表示标准制药一个要 \(x\) 秒,给你 \(s\) 表示你的法力值为\(s\)

\(m\) 种第一类魔法,消耗 \(b\) 点法力值,缩短时间为 \(a\) 秒。

\(k\) 种第二类魔法,消耗 \(d\) 点法力值,瞬间做出 \(c\) 个药。

两种魔法最多各选一个用,问你最少花多少时间能制得至少 \(n\) 个药剂

分析:

  1. 首先按第一种药剂以能缩短的时间为第一关键字,以消耗的法力值为第二关键字排序。

  2. 枚举第一种药剂,二分第二种药剂即可。

Code

#include <bits/stdc++.h>
using namespace std;

const int INF= 0x3f3f3f3f;
const int N=2e5+5;
typedef long long LL;

LL n,m,k,w,s;
LL b[N],c[N];

struct Node
{
	LL cost;
	LL changeto;
} a[N];

int main()
{
	scanf("%d%d%d%d%d",&n,&m,&k,&w,&s);
	for(int i=1; i<=m; i++) scanf("%d",&a[i].cost);
	for(int i=1; i<=m; i++) scanf("%d",&a[i].changeto);
	for(int i=1; i<=k; i++) scanf("%d",&b[i]);
	for(int i=1; i<=k; i++) scanf("%d",&c[i]);

	LL time=n*w;
	for(int i=1; i<=k; i++)
	{
		if(c[i] <= s)
		{
			time=min(time, (n-b[i])*w );
		}
	}
	for(int i=1; i<=m; i++)
	{
		if(a[i].changeto <= s)
		{
			time=min(time, n*a[i].cost );
		}
	}
	for(int i=1; i<=m; i++)
	{
		if(a[i].changeto > s) continue;

		LL temp=upper_bound(c+1,c+1+k, s-a[i].changeto )-(c+1);
		if(c[temp] <= s-a[i].changeto)
			time=min(time, (n-b[temp])*a[i].cost) ;
	}
	
	cout<<time;

	return 0;
}

【题解】 CF734C Anton and Making Potions

原文:https://www.cnblogs.com/BorisDimitri/p/15142880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!