D - Maximizing Advertising
题目链接:https://cn.vjudge.net/contest/250168#problem/D
题目大意:给你一些点的坐标,这些点属于两个帮派,让你将这些点分进两个不能重叠的矩形中,问你最多两个矩形中不同帮派之和为多少?
具体思路:
将点分别按照x升序进行排序,按照y升序进行排序。横着扫描一遍,竖着扫描一遍,求出在扫描的过程中和的最大值。
AC代码;
#include<bits/stdc++.h>
using namespace std;
# define maxn 1000000+10
struct node
{
int x,y;
char cost;
} q[maxn];
bool cmp1(node t1,node t2)
{
return t1.x<t2.x;
}
bool cmp2(node t1,node t2)
{
return t1.y<t2.y;
}
int xb[maxn],xw[maxn],yb[maxn],yw[maxn];
void init()
{
memset(xb,0,sizeof(xb));
memset(xw,0,sizeof(xw));
memset(yb,0,sizeof(yb));
memset(yw,0,sizeof(yw));
}
int main()
{
int n;
scanf("%d",&n);
getchar();
for(int i=1; i<=n; i++)
{
scanf("%d %d %c",&q[i].x,&q[i].y,&q[i].cost);
}
sort(q+1,q+n+1,cmp1);
for(int i=1; i<=n; i++)
{
if(q[i].cost=='b')
{
xb[i]++;
}
if(q[i].cost=='w')
{
xw[i]++;
}
xb[i]+=xb[i-1];
xw[i]+=xw[i-1];//求x的前缀和
}
sort(q+1,q+n+1,cmp2);
for(int i=1; i<=n; i++)
{
if(q[i].cost=='b')
{
yb[i]++;
}
if(q[i].cost=='w')
{
yw[i]++;
}
yb[i]+=yb[i-1];
yw[i]+=yw[i-1];//求y的前缀和
}
int maxx=-1;
for(int i=1; i<=n; i++)
{
int temp1=xb[i]+xw[n]-xw[i];
int temp2=xw[i]+xb[n]-xb[i];
maxx=max(maxx,max(temp1,temp2));
}
for(int i=1; i<=n; i++)
{
int temp1=yb[i]+yw[n]-yw[i];
int temp2=yw[i]+yb[n]-yb[i];
maxx=max(maxx,max(temp1,temp2));
}
printf("%d\n",maxx);
return 0;
}
D - Maximizing Advertising的更多相关文章
- Gym .101879 USP Try-outs (寒假自训第七场)
B .Aesthetics in poetry 题意:给定N个数,(N<2000 ,a[i] <=1e9),让你找一个最大的K,使得N个数膜K的余数个数全都等于N/K个. 思路:我们找到N ...
- (寒假开黑gym)2018 USP Try-outs
layout: post title: (寒假开黑gym)2018 USP Try-outs author: "luowentaoaa" catalog: true tags: m ...
- [Computational Advertising] 计算广告学笔记之基础概念
因为工作需要,最近一直在关注计算广告学的内容.作为一个新手,学习计算广告学还是建议先看一下刘鹏老师在师徒网的教程<计算广告学>. 有关刘鹏老师的个人介绍:刘鹏现任360商业产品首席架构师, ...
- 关于Advertising Campaign
Advertise Campaigns 是指为了传播企业创意或者宣传主题而采取的一些列的整合营销(IMC)活动,也称为广告战役.广告战役主要在一段明确的时间内,通过不同的媒体渠道投放广告,现在经常会整 ...
- Learning Bayesian Network Classifiers by Maximizing Conditional Likelihood
Abstract Bayesian networks are a powerful probabilistic representation, and their use for classifica ...
- Baidu set to lose leading role in digital advertising _china daily
advertising: n,广告 Online search giant Baidu Inc is set to loset its top spot in the nation's booming ...
- controlling the variance of request response times and not just worrying about maximizing queries per second
http://highscalability.com/blog/2010/11/4/facebook-at-13-million-queries-per-second-recommends-minim ...
- IDFA问题,苹果上传问题。improper Advertising identifier [IDFA] Usage.
原地址: 报告 improper Advertising identifier [IDFA] Usage. Your app contains the Advertising Identifier [ ...
- 微软的一篇ctr预估的论文:Web-Scale Bayesian Click-Through Rate Prediction for Sponsored Search Advertising in Microsoft’s Bing Search Engine。
周末看了一下这篇论文,觉得挺难的,后来想想是ICML的论文,也就明白为什么了. 先简单记录下来,以后会继续添加内容. 主要参考了论文Web-Scale Bayesian Click-Through R ...
随机推荐
- UVALive5876-Writings on the Wall-KMP
有两段字符串,第一段的尾和第二段的头可能重合.问有多少种组合的可能. 需要理解一下next数组的意义. #include <cstdio> #include <cstring> ...
- ssm 整合 redis(进阶教程)
最后我建议大家使用 Spring StringRedisTemplate 配置,参阅: http://blog.csdn.net/hanjun0612/article/details/78131333 ...
- Maven依赖中的scope详解
scope的分类 compile 默认就是compile,什么都不配置也就是意味着compile.compile表示被依赖项目需要参与当前项目的编译,当然后续的测试,运行周期也参与其中,是一个比较强的 ...
- ANDROID content provide 使用实例
Content Provider提供了一种多应用间数据共享的方式,比如:联系人信息可以被多个应用程序访问.Content Provider是个实现了一组用于提供其他应用程序存取数据的标准方法的类. 下 ...
- NOIP2014题解
NOIP2014题解 Day1 生活大爆炸版石头剪刀布 rps 简单模拟题,注意细节 #include<iostream> #include<cstdio> using nam ...
- hdu 2870 Largest Submatrix(平面直方图的最大面积 变形)
Problem Description Now here is a matrix with letter 'a','b','c','w','x','y','z' and you can change ...
- 标准C++类std::string的内存共享和Copy-On-Write...
标准C++类std::string的 内存共享和Copy-On-Write技术 陈皓 1. 概念 Scott Meyers在<More Effective C++>中举了个例子,不知你是否 ...
- Linux 常用命令——which, whereis, locate, find
转载请注明出处:http://blog.csdn.net/drecik__/article/details/8455399 1. which 查找使用命令所在的位置 2. whereis 搜索文件,跟 ...
- 初次认识:Transfer-Encoding: chunked
Transfer-Encoding: chunked 表示输出的内容长度不能确定,普通的静态页面.图片之类的基本上都用不到这个. 但动态页面就有可能会用到,但我也注意到大部分asp,php,asp.n ...
- JAVA过滤器的使用(Filter)
request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf ...