【题解】 CF734C Anton and Making Potions 题意 分析: Code

要求得到至少 (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;
}