zoukankan      html  css  js  c++  java
  • 【题解】 CF734C Anton and Making Potions

    题意

    要求得到至少 (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;
    }
    
  • 相关阅读:
    DevExpress中设置PanelControl背景的方法
    ArcEngine选中面要素样式修改
    DEV winform treelist设置背景图像
    React-Native运行知乎日报遇到的问题
    winform程序自动升级
    jquery图片轮播效果(unslider)
    Orchard搜索与索引
    网络版会飞的小鸟
    jQuery event的复制粘贴的坑
    记一次有趣的互联网事件及console.log~
  • 原文地址:https://www.cnblogs.com/BorisDimitri/p/15142880.html
Copyright © 2011-2022 走看看