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 ...
随机推荐
- Django的ORM常用查询操作总结(Django编程-3)
Django的ORM常用查询操作总结(Django编程-3) 示例:一个Student model: class Student(models.Model): name=models.CharFiel ...
- BZOJ3425[POI2013]Polarization——DP+bitset+分块
题目描述 Everyone knew it would only be a matter of time. So what? Faced for years on, a peril becomes t ...
- BZOJ3417[Poi2013]Tales of seafaring——BFS
题目描述 Young Bytensson loves to hang out in the port tavern, where he often listens to the sea dogs te ...
- BZOJ1041 HAOI2008圆上的整点(数论)
求x2+y2=r2的整数解个数,显然要化化式子.考虑求正整数解. y2=r2-x2→y2=(r-x)(r+x)→(r-x)(r+x)为完全平方数→(r-x)(r+x)/d2为完全平方数,d=gcd(r ...
- C# 文件比较差异
参考:https://www.cnblogs.com/vaevvaev/p/7115721.html 这里我就比较2个文件 使用了fc命令. 2个文件路径如下 path1,path2 static ...
- SDL源码阅读笔记(1) 基本模块
write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie 前言 对于大牛来说,写关于阅读源码的文章都会叫源码剖析或者深入浅出啥的,对于我,自己阅读阅读源码,写 ...
- Luogu 2680 NOIP 2015 运输计划(树链剖分,LCA,树状数组,树的重心,二分,差分)
Luogu 2680 NOIP 2015 运输计划(树链剖分,LCA,树状数组,树的重心,二分,差分) Description L 国有 n 个星球,还有 n-1 条双向航道,每条航道建立在两个星球之 ...
- asp 调用 vb(activex dll) ,参数传递(传引用)需要注意
今天上午测试 vb 与 c(dll) 之间交互,传递参数的时候,没遇到什么太大的问题. 下午在asp中调用vb(activex dll)时, 在asp代码中传参数到 vb(dll)中时,遇到问题了. ...
- 装饰页面decorators.xml
WEB-INF/decorators.xml 这个配置可以增加页面的 装饰页面
- Arcgis api 离线部署
Arcgis api 离线部署 修改 文件一(init.js)位置:arcgis_js_v317_api\arcgis_js_api\library\3.17\3.17\init.js 将[HOSTN ...