Codeforces Beta Round #12 (Div 2 Only) D. Ball sort/map
D. Ball
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/problemset/problem/12/D
Description
Input
The first line contains one integer N (1 ≤ N ≤ 500000). The second line contains N integer numbers Bi, separated by single spaces. The third and the fourth lines contain sequences Ii and Ri in the same format. It is guaranteed that 0 ≤ Bi, Ii, Ri ≤ 109.
Output
Output the answer to the problem.
Sample Input
3
1 4 2
4 3 2
2 5 3
Sample Output
1
HINT
题意
如果存在A女的三个属性都比B女高,那么B女就会自杀,然后问你有多少女的自杀了
题解:
排序,之后,然后用map搞一搞
较为详细的题解:http://blog.csdn.net/qiqijianglu/article/details/8494186
代码
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1000010
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff;
const int inf=0x3f3f3f3f;
/* inline void P(int x)
{
Num=0;if(!x){putchar('0');puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
*/
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** struct node
{
int a,b,c; }la[maxn];
bool cmp(node aa,node bb)
{
if(aa.a!=bb.a)return aa.a<bb.a;
if(aa.b!=bb.b)return aa.b>bb.b;
return aa.c<bb.c;
}
map<int,int> M;
map<int,int>::iterator it;
int main()
{
int n=read();
for(int i=;i<=n;i++)
la[i].a=read();
for(int i=;i<=n;i++)
la[i].b=read();
for(int i=;i<=n;i++)
la[i].c=read();
sort(la+,la++n,cmp);
M[-inf]=inf;
M[inf]=-inf;
int ans=;
for(int i=n;i>=;i--)
{
it=M.upper_bound(la[i].b);
if(la[i].c<it->second)
ans++;
else
{
if(M[la[i].b]<la[i].c)
{
M[la[i].b]=la[i].c;
for(it=--M.lower_bound(la[i].b);it->second<=la[i].c;)
M.erase(it--);
}
}
}
cout<<ans<<endl;
}
Codeforces Beta Round #12 (Div 2 Only) D. Ball sort/map的更多相关文章
- Codeforces Beta Round #12 (Div 2 Only) D. Ball 树状数组查询后缀、最值
http://codeforces.com/problemset/problem/12/D 这里的BIT查询,指的是查询[1, R]或者[R, maxn]之间的最值,这样就够用了. 设三个权值分别是b ...
- Codeforces Beta Round #12 (Div 2 Only)
Codeforces Beta Round #12 (Div 2 Only) http://codeforces.com/contest/12 A 水题 #include<bits/stdc++ ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- Aptana 插件 for Eclipse 4.4
http://download.aptana.com/studio3/plugin/install Aptana Update Site This site is designed to be use ...
- Groovy获取json和xml数据
如果是xml就用这个 // to read a node from your Response def grUtils = new com.eviware.soapui.support.GroovyU ...
- 【2013微软面试题】输出节点数为n的二叉树的所有形态
转自:http://blog.csdn.net/monsterxd/article/details/8449005 /* * 题意,求节点数为n的二叉树的所有形态,先要想个方式来唯一标示一棵二叉树 ...
- html5标签集结1
1.<bdo>标签:覆盖默认的文本方向. <bdo dir="ltr">Here is some text</bdo> 显示结果(从左到右): ...
- dom 优酷得弹出
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Spark RDD概念学习系列之RDD的checkpoint(九)
RDD的检查点 首先,要清楚.为什么spark要引入检查点机制?引入RDD的检查点? 答:如果缓存丢失了,则需要重新计算.如果计算特别复杂或者计算耗时特别多,那么缓存丢失对于整个Job的影响是不容 ...
- static_cast, dynamic_cast, const_cast探讨
转自:http://www.cnblogs.com/chio/archive/2007/07/18/822389.html 首先回顾一下C++类型转换: C++类型转换分为:隐式类型转换和显式类型转换 ...
- 游戏被App Store下架 如何快速上线?
游戏被App Store下架 如何快速上线? 发布者: sea_bug | 发布时间: 2014-12-20 14:17| 评论数: 0 近日,有媒体报道出国内某家CP的产品被苹果从App Store ...
- MYSQL数据库性能调优之八:mysql日志
MySQL日志 主要包含:错误日志.查询日志.慢查询日志.事务日志.二进制日志.中继日志: 使用 SHOW GLOBAL VARIABLES LIKE '%log%'; 查询所有日志配置详情: 一. ...
- C++11强类型枚举
[C++11强类型枚举] 在标准C++中,枚举类型不是类型安全的.枚举类型被视为整数,这使得两种不同的枚举类型之间可以进行比较.C++03 唯一提供的安全机制是一个整数或一个枚举型值不能隐式转换到另一 ...