有一个显然的想法是因为最后要花分成n*m个小块,所以每条边一定是要被切开的。

所以直接排序就可以了qwq,按照代价从大到小切一定是最优的。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int n,m,cur,cnt1=1,cnt2=1;
long long ans;
priority_queue<int,vector<int>,less<int> >q1,q2;
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<n;i++){scanf("%d",&cur);q1.push(cur);}
for(int i=1;i<m;i++){scanf("%d",&cur);q2.push(cur);}
while(!q1.empty()&&!q2.empty())
{
if(q1.top()>q2.top()){ans+=1ll*q1.top()*cnt2,cnt1++; q1.pop();}
else{ans+=1ll*q2.top()*cnt1,cnt2++; q2.pop();}
}
while(!q1.empty()){ans+=1ll*q1.top()*cnt2,cnt1++; q1.pop();}
while(!q2.empty()){ans+=1ll*q2.top()*cnt1,cnt2++; q2.pop();}
printf("%lld\n",ans);
return 0;
}

BZOJ2430 chocolate的更多相关文章

  1. 【bzoj2430】[Poi2003]Chocolate 贪心

    题目描述 有一块n*m的矩形巧克力,准备将它切成n*m块.巧克力上共有n-1条横线和m-1条竖线,你每次可以沿着其中的一条横线或竖线将巧克力切开,无论切割的长短,沿着每条横线切一次的代价依次为y1,y ...

  2. Big Chocolate

    Big Chocolate 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=19127 Big Chocolat ...

  3. Dividing a Chocolate(zoj 2705)

    Dividing a Chocolate zoj 2705 递推,找规律的题目: 具体思路见:http://blog.csdn.net/u010770930/article/details/97693 ...

  4. hdu----(4301)Divide Chocolate(状态打表)

    多校综合排名前25名的学校请发送邮件到HDUACM@QQ.COM,告知转账信息(支付宝或者卡号) Divide Chocolate Time Limit: 2000/1000 MS (Java/Oth ...

  5. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  6. Codeforces Round #310 (Div. 1) C. Case of Chocolate set

    C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...

  7. codeforces 678C C. Joty and Chocolate(水题)

    题目链接: C. Joty and Chocolate time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. CodeForces 689C Mike and Chocolate Thieves (二分+数论)

    Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...

  9. Educational Codeforces Round 1 E. Chocolate Bar 记忆化搜索

    E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/prob ...

随机推荐

  1. Java并发之AQS详解(转)

    一.概述 谈到并发,不得不谈ReentrantLock:而谈到ReentrantLock,不得不谈AbstractQueuedSynchronized(AQS)! 类如其名,抽象的队列式的同步器,AQ ...

  2. 【296】Python 默认 IDE 修改

    参考:找回Python IDLE Shell里的历史命令(用上下键翻历史命令怎么不好用了呢?) 参考:Python IDLE快捷键一览 参考:Python IDLE 自动提示功能 参考:如何让pyth ...

  3. 学习python必备的学习网站

    Django框架学习必备网站: 官方网站   https://www.djangoproject.com/ 1.11版英文文档   https://docs.djangoproject.com/en/ ...

  4. js使用浏览器的另存为下载文件

    页面上的页面如下: 我需要根据返回的url下载文件: js: //判断浏览器类型 function myBrowser(){ var userAgent = navigator.userAgent; ...

  5. yii2.0 报错Cookievalidationkey Must Be Configured With A Secret Key

    'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) ...

  6. IPP库下FFT的基本实现

    首先感谢韩昊同学,他的傅里叶分析入门给我们对数学公式不熟悉的人了解傅里叶算法打开了一扇窗户,其原文发表于知乎:https://zhuanlan.zhihu.com/p/19763358 在了解其基本原 ...

  7. Spring AOP 整理

    在 xml中加 xmlns:aop="http://www.springframework.org/schema/aop" http://www.springframework.o ...

  8. HDU 6069 Counting Divisors (素数+筛法)

    题意:给定 l,r,k,让你求,其中 l <= r <= 1e12, r-l <= 1e6, k <= 1e7. 析:首先这个题肯定不能暴力,但是给定的区间较小,可以考虑筛选, ...

  9. python-字符串-技巧

    1.删除字符串末尾空白:rstrip函数 test1 = "This is a test " print(test1.rstrip()) 但是这种删除只是暂时的,如果想永久删除,则 ...

  10. Linux-在新买的阿里云服务器上部署Tomcat并支持外网访问的配置(步骤记录)

    一.首先你得有一台外网上的服务器 华为.腾讯.阿里都有云服务售卖,我这里是在阿里云打折时购买的. 二.使用Xshell和XFTP连接上云服务 当然了,连接工具有很多种,可随意.购买服务器之后,你会收到 ...