题意:

要生产n个物品,每个花费时间为x。

有两种魔法,每种最多使用1个。

其中第一种魔法可以使每个物品生产的花费时间变为ai,相应的花费是bi;
第二种魔法可以减少ci个物品,相应的花费是di,并且保证对于i<j ci<=cj 且 di<=dj;

#include<bits/stdc++.h>
using namespace std;
long long b[],c[],d[];
pair<long long ,long long>a[];
long long inf=0x3f3f3f3f3f3f3f3f;
int main()
{
long long n,m,k,x,s;
scanf("%lld%lld%lld%lld%lld",&n,&m,&k,&x,&s);
for(int i=;i<=m;i++)scanf("%lld",&a[i].second);
for(int i=;i<=m;i++)scanf("%lld",&a[i].first);
for(int i=;i<=k;i++)scanf("%lld",c+i);
for(int i=;i<=k;i++)scanf("%lld",d+i);
long long ans=n*x;
sort(a+,a+m+);
int j=;
long long mina=x;
for(int i=k;i>=;i--){
while(j<=m&&a[j].first+d[i]<=s){
mina=min(mina,a[j].second);
j++;
}
if(d[i]<=s){
ans=min(ans,(n-c[i])*mina);
}
}
printf("%lld\n",ans);
}

Codeforces 734C [水][暴力][贪心]的更多相关文章

  1. Codeforces 913 二进制背包(柠檬水) 暴力贪心特殊背包(选题)

    A B C 给你N(N<=30)种水瓶每种水瓶有无限个 每个的体积是2^(i-1)价格是cost[i] 要求你花最少的钱弄出L体积的水 先从前到后扫一遍cost[i+1]=min(cost[i+ ...

  2. Codeforces Round #503 (by SIS, Div. 2) C. Elections (暴力+贪心)

    [题目描述] Elections are coming. You know the number of voters and the number of parties — n and m respe ...

  3. codeforces 704B - Ant Man 贪心

    codeforces 704B - Ant Man 贪心 题意:n个点,每个点有5个值,每次从一个点跳到另一个点,向左跳:abs(b.x-a.x)+a.ll+b.rr 向右跳:abs(b.x-a.x) ...

  4. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解&源码(A.水+暴力,B.dp+栈)

    A.喵哈哈村的魔法石 发布时间: 2017年2月21日 20:05   最后更新: 2017年2月21日 20:06   时间限制: 1000ms   内存限制: 128M 描述 传说喵哈哈村有三种神 ...

  5. CodeForces - 50A Domino piling (贪心+递归)

    CodeForces - 50A Domino piling (贪心+递归) 题意分析 奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0. 代码 #include ...

  6. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  7. Codeforces 990 调和级数路灯贪心暴力 DFS生成树两子树差调水 GCD树连通块暴力

    A 水题 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) using namespace ...

  8. Codeforces Beta Round #37 B. Computer Game 暴力 贪心

    B. Computer Game 题目连接: http://www.codeforces.com/contest/37/problem/B Description Vasya's elder brot ...

  9. Codeforces Round #407 (Div. 2)A B C 水 暴力 最大子序列和

    A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...

随机推荐

  1. MySQL安装教程&Navicat安装

    一.下载MySQL http://jingyan.baidu.com/article/e3c78d64412ae83c4c85f5fd.html 首先打开MySQL官网,找到Downloads标签,点 ...

  2. SSH进阶之路

    [SSH进阶之路]Hibernate基本原理(一)       在开始学Hibernate之前,一直就有人说:Hibernate并不难,无非是对JDBC进一步封装.一句不难,难道是真的不难还是眼高手低 ...

  3. 2、HTML基础总结 part-2

    1.表单一 <html> <body> <form> 姓名: <input type="text" name="name&quo ...

  4. python 列表、元组 详解

    python中有6种序列的内置类型,分别为:列表,元组,字符串,Unicode字符串,buffer对象和xrange对象 列表和元组是最常见两种类型. 下面将以列表(list)和元组(tuple)为例 ...

  5. Matlab freqs 函数

    freqs 模拟滤波器的频率响应 语法: h = freqs(b,a,w)[h,w] = freqs(b,a)[h,w] = freqs(b,a,f)freqs(b,a) 描述: freqs 返回一个 ...

  6. Git 笔记 - section 1

    1. 创建版本库 创建目录 git init git add <file> git commit -m "本次提交内容的说明" 2. 查看状态 git status g ...

  7. 给出 中序&后序 序列 建树;给出 先序&中序 序列 建树

    已知 中序&后序  建立二叉树: SDUT 1489 Description  已知一棵二叉树的中序遍历和后序遍历,求二叉树的先序遍历 Input  输入数据有多组,第一行是一个整数t (t& ...

  8. iOS---Objective-C: +load vs +initialize

    在 NSObject 类中有两个非常特殊的类方法 +load 和 +initialize ,用于类的初始化.这两个看似非常简单的类方法在许多方面会让人感到困惑,比如: 子类.父类.分类中的相应方法什么 ...

  9. 【bzoj2721】[Violet 5]樱花 数论

    题目描述 输入 输出 样例输入 2 样例输出 3 题解 数论 设1/x+1/y=1/m,那么xm+ym=xy,所以xy-xm-ym+m^2=m^2,所以(x-m)(y-m)=m^2. 所以解的数量就是 ...

  10. UVALive 6319 暴力

    思路:直接vector暴力 #include<iostream> #include<vector> #include<cstring> #include<cs ...