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 ...
随机推荐
- UOJ #76 【UR #6】懒癌
确实是一道很不错的题啊. 题目链接 题意 感觉也没什么特别简洁的版本,大家直接看题面吧. 题解 我第一次看到这个类似问题的背景是疯狗,因此下面的题解不自觉的代入了...大家明白意思就好. 我们考虑对于 ...
- Luogu4512 【模板】多项式除法(多项式求逆+NTT)
http://blog.miskcoo.com/2015/05/polynomial-division 好神啊! 通过翻转多项式消除余数的影响,主要原理是商只与次数不小于m的项有关. #include ...
- Redis之发布订阅
一 什么是发布订阅 发布订阅模式又叫观察者模式,它定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖它的对象都将得到通知 Redis 发布订阅(pub/sub)是一种消息通信模式: ...
- 自学Aruba2.1-Aruba Web UI --Dashbord面板介绍
点击返回:自学Aruba之路 自学Aruba2.1-Aruba Web UI --Dashbord面板介绍 本文所有设计的的controller版本信息如下: Aruba7205 V6.4.4.16 ...
- [hdu3966]Aragorn's Story
传送门 题目描述 Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One ...
- emWin 文字图形同时刷新导致图形显示异常
@2018-7-10 实现目标 一 BUTTON 控制文字图形的刷新切换,具体为 BUTTON 初次按下,文字显示为 “开始” .填充圆显示为绿色,再次按下,文字显示为 “停止” .填充圆显示为红色 ...
- luogu2312 [NOIp2015]解方程 (秦九韶)
秦九韶算法:多项式$a_0+a_1x+a_2x^2+...+a_nx^n=a_0+x(a_1+x(a_2+...+(xa_n))..)$,这样对于一个x,可以在O(n)求出结果 为了避免高精度,我们同 ...
- Java NIO -- 阻塞和非阻塞
传统的 IO 流都是阻塞式的.也就是说,当一个线程调用 read() 或 write()时,该线程被阻塞,直到有一些数据被读取或写入,该线程在此期间不能执行其他任务.因此,在完成网络通信进行 IO操作 ...
- Arch Linux中禁用UTC解决双系统时间问题
原因 Windows双系统时间不统一在于时间表示有两个标准:localtime 和 UTC(Coordinated Universal Time) .UTC 是与时区无关的全球时间标准.尽管概念上有差 ...
- A1020. Tree Traversals
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and i ...