题目链接: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的更多相关文章

  1. Gym .101879 USP Try-outs (寒假自训第七场)

    B .Aesthetics in poetry 题意:给定N个数,(N<2000 ,a[i] <=1e9),让你找一个最大的K,使得N个数膜K的余数个数全都等于N/K个. 思路:我们找到N ...

  2. (寒假开黑gym)2018 USP Try-outs

    layout: post title: (寒假开黑gym)2018 USP Try-outs author: "luowentaoaa" catalog: true tags: m ...

  3. [Computational Advertising] 计算广告学笔记之基础概念

    因为工作需要,最近一直在关注计算广告学的内容.作为一个新手,学习计算广告学还是建议先看一下刘鹏老师在师徒网的教程<计算广告学>. 有关刘鹏老师的个人介绍:刘鹏现任360商业产品首席架构师, ...

  4. 关于Advertising Campaign

    Advertise Campaigns 是指为了传播企业创意或者宣传主题而采取的一些列的整合营销(IMC)活动,也称为广告战役.广告战役主要在一段明确的时间内,通过不同的媒体渠道投放广告,现在经常会整 ...

  5. Learning Bayesian Network Classifiers by Maximizing Conditional Likelihood

    Abstract Bayesian networks are a powerful probabilistic representation, and their use for classifica ...

  6. 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 ...

  7. 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 ...

  8. IDFA问题,苹果上传问题。improper Advertising identifier [IDFA] Usage.

    原地址: 报告 improper Advertising identifier [IDFA] Usage. Your app contains the Advertising Identifier [ ...

  9. 微软的一篇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 ...

随机推荐

  1. codeforces742B

    Arpa’s obvious problem and Mehrdad’s terrible solution CodeForces - 742B There are some beautiful gi ...

  2. BZOJ[Usaco2017 Jan]Promotion Counting——线段树合并

    题目描述 The cows have once again tried to form a startup company, failing to remember from past experie ...

  3. js md5 中文

    最近手机端通过js对请求数据加密,发现针对中文加密的结果和asp.net的webapi加密结果不一致 网上搜索了一下,发现以下js可用 function md5(string) { var x = A ...

  4. The Unique MST POJ - 1679 (次小生成树)

    Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spann ...

  5. instanceof判断的对象可以是接口

    instanceof是Java的一个二元操作符(运算符) 用法 boolean result = object instanceof class instanceof通过返回一个布尔值来指出,这个对象 ...

  6. 投入机器学习的怀抱?先学Python吧

    前两天写了篇文章,给想进程序员这个行当的同学们一点建议,没想到反响这么好,关注和阅读数都上了新高度,有点人生巅峰的感觉呀.今天趁热打铁,聊聊我最喜欢的编程语言——Python. 为什么要说Python ...

  7. Shell基础知识(三)

    Shell中变量的作用域: 在当前Shell会话中使用,全局变量. 在函数内部使用,局部变量. 可以在其他Shell会话中使用,环境变量. 局部变量: 默认情况下函数内的变量也是全局变量 #!/bin ...

  8. 洛谷 P2587 [ZJOI2008]泡泡堂 解题报告

    P2587 [ZJOI2008]泡泡堂 题目描述 第XXXX届NOI期间,为了加强各省选手之间的交流,组委会决定组织一场省际电子竞技大赛,每一个省的代表队由n名选手组成,比赛的项目是老少咸宜的网络游戏 ...

  9. Java内存模型基础

    Java内存模型的基础 并发编程模型的两个关键问题 在并发编程种,需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来交换信息.在 ...

  10. JS数组冒泡排序&去重

    冒泡排序: var a = [2,1,4,3,6,5]; for(var d = 0 ; d< a.length; d++){ for(var b = d+1; b < a.length; ...