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> ...
随机推荐
- 12、NFC技术:读写NFC标签中的Uri数据
功能实现,如下代码所示: 读写NFC标签的Uri 主Activity import cn.read.write.uri.library.UriRecord; import android.app.Ac ...
- delphi中通过CreateOleObject操控Word
http://blog.csdn.net/csm2432/article/details/7692443
- md5加密算法c语言版
from: http://blog.sina.com.cn/s/blog_693de6100101kcu6.html 注:以下是md5加密算法c语言版(16/32位) ---------------- ...
- 字符串和数组中split().toString(),join(),splice(),slice(),substr()和substring()
<!Doctype html> <head> <mate charset="utf-8"> <title>string change ...
- 10个常见的IE bug和解决方法
1.IE6 幽灵文本(Ghost Text bug) 在我写本文之前,我遇到了这个bug.它相当的古怪和滑稽.一块不知哪来的重复的文本,被IE6显示在靠近原文本的下面.(译注:也可以参看 Explor ...
- PV3D学习笔记-导入DAE模型
网上关于PV3D导入DAE模型的例子都非常多,可惜我研究了半天,一个都没成功,或者是破面问题,或者是贴图不显示,再或者贴图乱掉了.今天晚上终于搞定,心得发上来. 制作模型的软件是SketchUp ...
- 第一百九十五天 how can I 坚持
晚上回来又肚子疼,拉肚子,咋搞的呢. 小米.华为.感觉虽然现在华为有些许优势,哎,还是不说了,感觉小米手机信号好像有问题. 中午吃的刀削面好像不熟,其实,怎么说呢,像开面馆,做的面顾客都吃不完,很明显 ...
- E2202 Required package 'VclJPG' not found
xe8 [dcc32 Fatal Error] RaizeComponentsVcl_Design.dpk(40): E2202 Required package 'VclJPG' not found ...
- LeetCode104: Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- LeetCode 刷题记录
写在前面:因为要准备面试,开始了在[LeetCode]上刷题的历程.LeetCode上一共有大约150道题目,本文记录我在<http://oj.leetcode.com>上AC的所有题目, ...