博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1037. Magic Coupon (25)
阅读量:4151 次
发布时间:2019-05-25

本文共 974 字,大约阅读时间需要 3 分钟。

两数组之间操作事件的模拟

#include
#include
struct myComp{ bool operator()(const int& a, const int& b) { return a > b; }};int main(){ int nc, np; while(scanf("%d",&nc)!=EOF) { std::multiset
c1, p1; std::multiset
c2, p2;//negtive while(nc--) { int tmp; scanf("%d",&tmp); if(tmp>=0) c1.insert(tmp); else c2.insert(tmp); } scanf("%d",&np); while(np--) { int tmp; scanf("%d",&tmp); if(tmp>=0) p1.insert(tmp); else p2.insert(tmp); } //get the max int max = 0; while(!c1.empty() && !p1.empty()) { std::multiset
::iterator it1, it2; it1 = c1.begin(); it2 = p1.begin(); int a = (*it1); int b = (*it2); max += a*b; c1.erase(it1); p1.erase(it2); } while(!c2.empty() && !p2.empty()) { std::multiset
::iterator it1, it2; it1 = c2.begin(); it2 = p2.begin(); int a = (*it1); int b = (*it2); max += a*b; c2.erase(it1); p2.erase(it2); } //output printf("%d\n", max); } return 0;}

 

转载地址:http://saxti.baihongyu.com/

你可能感兴趣的文章
Spring中Quartz的配置
查看>>
Hadoop视频学习地址
查看>>
封装JAVA 通过反射 POI导出Excel文件(直接可用 含测试代码)
查看>>
jquery省市县 三级联动
查看>>
使用Ztree 默认的增删改操作 和 自定义增删改按钮(是操作数据库实例,比较简单的修改了下)...
查看>>
spring AOP记录日志
查看>>
优化MySQL数据库性能
查看>>
45 个非常有用的 Oracle 查询语句
查看>>
找工作的一些感悟
查看>>
JDK6和JDK7中的substring()方法
查看>>
Java中的equals()和hashCode()契约
查看>>
如何使用建造者模式(Builder Pattern)创建不可变类
查看>>
Java你不知道的那些事儿—Java隐藏特性(上)
查看>>
使用Java创建RESTful Web Service
查看>>
Google Guava 库用法整理
查看>>
google的guava工具类splitter和apache stringutil对比
查看>>
关注google的guava工具包Map集合
查看>>
guava 15新特性介绍
查看>>
google guava的splitter用法
查看>>
Guava API学习之Optional 判断对象是否为null
查看>>