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 ...
随机推荐
- ceph S3测试--cosbench
COSBench安装 Cosbench是Intel的开源云存储性能测试软件,COSBench目前已经广泛使用与云存储测试,并作为云存储的基准测试工具使用 1 环境 1.1 操作系统 COSBench可 ...
- Django实现websocket完成实时通讯,聊天室,在线客服等
一 什么是Websocket WebSocket是一种在单个TCP连接上进行全双工通信的协议 WebSocket使得客户端和服务器之间的数据交换变得更加简单,允许服务端主动向客户端推送数据.在WebS ...
- 洛谷P1776 宝物筛选_NOI导刊2010提高(02)(多重背包,单调队列)
为了学习单调队列优化DP奔向了此题... 基础的多重背包就不展开了.设\(f_{i,j}\)为选前\(i\)个物品,重量不超过\(j\)的最大价值,\(w\)为重量,\(v\)为价值(蒟蒻有强迫症,特 ...
- Android手势监听类GestureDetector的使用
在使用自定义视图的时候,对触屏事件的处理是比不可少的,有能力的可以自己写代码处理,这样更加的灵活.如果不想这么麻烦,Android提供了一个手势监听类GestureDetector,可以供我们使用.G ...
- Linux下配置ssh免密远程登录
步骤 使用ssh-keygen生成密钥对 提示要求输入保存的位置,密码等信息.全部使用默认信息即可 使用ssh-copy-id user@host将公钥拷贝到需要免密登录的服务器的账户中. 例如,需要 ...
- js的append拼接html丢失css样式解决
htmlApp += "<li id='leftli"+lunci+"'>"; htmlApp += "<span id='left ...
- 【LOJ#6282】数列分块6
题目大意:给定一个由 N 个数组成的序列,维护两种操作:单点询问,单点插入.N < 100000 题解:在块内维护一个链表,支持动态插入数字,同时对于非随即数据来说,若块的大小过大,需要重构. ...
- 出现“java.lang.AssertionError: SAM dictionaries are not the same”报错
运行一下程序时出现“java.lang.AssertionError: SAM dictionaries are not the same”报错 java -jar picard.jar SortVc ...
- EOJ2018.10 月赛
EOJ2018.10 月赛 题目一览表(Green color indicate understand and Accept) 来源 考察知识点 完成时间 A oxx 的小姐姐们 EOJ 数学+思维 ...
- xargs与exec详解
一.场景 这个命令是错误的 1 find ./ -perm +700 |ls -l 这样才是正确的 1 find ./ -perm +700 |xargs ls -l 二.用法 1 2 3 4 5 ...