有一个显然的想法是因为最后要花分成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. nexus3 搭建maven远程仓库

    右上角 下载maven http://maven.apache.org/download.cgi 下载nexus https://www.sonatype.com/download-oss-sonat ...

  2. Bootstrip 的select的数据绑定问题

    这个问题浪费了我整整一个下午时间 最后终于解决了  这里来备份一下 $(function(){ var stu_no = freeUrl(); var data, subname="&quo ...

  3. linux tar 压缩

    压缩文件 tar -czvf xxx.tar.gz yourdict 解压文件 tar xzf aa.tar.gz

  4. 并发编程之IO模型比较和Selectors模块

    主要内容: 一.IO模型比较分析 二.selectors模块 1️⃣ IO模型比较分析 1.前情回顾: 上一小节中,我们已经分别介绍过了IO模型的四个模块,那么我想大多数都会和我一样好奇, 阻塞IO和 ...

  5. Spark之 RDD

    简介 RDD(Resilient Distributed Dataset)叫做弹性分布式数据集,是Spark中最基本的数据抽象,它代表一个不可变.可分区.里面的元素可并行计算的集合. Resilien ...

  6. Spring Data Jpa使用@Query注解实现模糊查询(LIKE关键字)

    /** * * @param file_name 传入参数 * @return */ @Query(value = "select * from user where name LIKE C ...

  7. android-tip-SocketException之ETIMEDOUT

    异常出现时间 如果我们有一个长连接,此时网络被关闭,或者暂时失去信号, 此时就会出现此异常. 如果出现此异常,则不得不重连.

  8. vmware Selinux配置错误,导致无法启动虚拟机

    Linux 开机提示kernel panic - not syncing: Attempted to kill init! 解决方法: 系统启动的时候,按下‘e’键进入grub编辑界面,编辑grub菜 ...

  9. Python String模块详解

    >>> import string >>> string.ascii_letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL ...

  10. json操作工具-LitJson

    LitJSON是json生成与读取的操作工具,使用很方便并且网上还能找到源码.下面是使用LitJSON的例子: 一.生成json:实例化一个JsonData,然后按照List数组的方式向里面填. Js ...