Codeforces Round #552 (Div. 3) F. Shovels Shop(dp)
题目链接
大意:给你n个物品和m种优惠方式,让你买k种,问最少多少钱。
思路:考虑dpdpdp,dp[x]dp[x]dp[x]表示买xxx种物品的最少花费,然后遍历mmm种优惠方式就行转移就好了。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,m,a[N],k;
struct uzi
{
int a,b;
bool operator <(const uzi & t)const{
return b>t.b;
}
}p[N];
LL dp[2033],s[N];
int main(){
ios::sync_with_stdio(false);
cin>>n>>m>>k;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
for(int i=1;i<=m;i++)cin>>p[i].a>>p[i].b;
for(int i=1;i<=k;i++){
dp[i]=dp[i-1]+a[i];
for(int j=1;j<=m;j++){
if(p[j].a<=i){
int l=i-p[j].a;
dp[i]=min(dp[i],dp[i-p[j].a]+s[i]-s[l]+s[i-p[j].a]-s[i+p[j].b-p[j].a]);
}
}
}
cout<<dp[k]<<endl;
return 0;
}
Codeforces Round #552 (Div. 3) F. Shovels Shop(dp)的更多相关文章
- Codeforces Round #552 (Div. 3) F. Shovels Shop (前缀和预处理+贪心+dp)
题目:http://codeforces.com/contest/1154/problem/F 题意:给你n个商品,然后还有m个特价活动,你买满x件就把你当前的x件中最便宜的y件价格免费,问你买k件花 ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...
- Codeforces Round #245 (Div. 1) B. Working out (dp)
题目:http://codeforces.com/problemset/problem/429/B 第一个人初始位置在(1,1),他必须走到(n,m)只能往下或者往右 第二个人初始位置在(n,1),他 ...
- Codeforces Round #260 (Div. 1) 455 A. Boredom (DP)
题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory l ...
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics (DP)
C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees (DP)
C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...
随机推荐
- shell编程企业级实战(2)
Vim配置文件.vimrc vim配置文件 if 条件语句 if是最常见的条件判断语句 例1:如果不存在/backup目录就创建. [root@web-01 /server/tools]# vim 0 ...
- Host Only、NAT和Bridge三种网络连接
Host Only.NAT和Bridge三种网络连接 在安装好了Linux镜像之后,如何连接物理机和虚拟机呢?这就需要网络连接,网络连接有三种:HostOnly.NAT.Bridge,它们都可用于Gu ...
- 复习交换代数——Noether正规化
目录 简介 初等启发 证明过程 几何意义 定理应用 参考资料 简介 在交换代数中有如下定理 Noether正规化引理 令$R$是一个有限生成$k$-代数整环,则存在$t_1,\ldots,t_n\in ...
- git总结二、关于分支上——好好认识下分支是怎么回事
同样需要先来明确两件事: HEAD指针指向的是当前分支 分支(master, dev)指向的是最新的提交 一开始,git 中只有一个master分支,严格来讲,HEAD不是指向提交而是指向master ...
- NPOI的基本用法,导出Excel
void DownloadForAccountIndex(IReadOnlyList<AccountInfoView> list) { NPOI.HSSF.UserModel.HSSFWo ...
- 关于TVWALL 通过AS300获取状态连接失败
昨天晚会突然之间频繁出现tvwall视频软件,断开AS300管理软件的故障 发现AS300当中的cms服务进程,占用内存250M左右,一般情况下估计就是50M左右,增长了不少 无奈之下,只有重启AS3 ...
- IntelliJ IDEA远程调试(Debug)Tomcat
为什么需要这么做? 解决 在我本地是好的啊 这个世界性难题- 测试环境碰到问题,直接连上debug,不用再测试本地,再查看测试环境日志 遇到一些诡异的问题,日志是看不出端倪的 调试一些只能在测试环境执 ...
- Oracle表之间关联更新
经常会遇到一个表需要根据另一个表数据来更新数据,总结了核心的sql脚本命令如下: A表如下x y--------------ka dakb dbkc ...
- Python神器 Jupyter Notebook
什么是Jupyter Notebook? 简介 Jupyter Notebook是基于网页的用于交互计算的应用程序.其可被应用于全过程计算:开发.文档编写.运行代码和展示结果. Jupyter Not ...
- markdown生成的a标签如何在新页面打开
原始的超链接语法这样写:[超链接的名字](url) 在新窗口中打开:[超链接的名字](url?_blank) 在本窗口中打开:[超链接的名字](url?_self)默认是在本窗口中打开 但上面的说法貌 ...