标签:
Time Limit: 20 Sec
Memory Limit: 256 MB
http://codeforces.com/problemset/problem/12/D
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
题意
如果存在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[20]; //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=0,f=1;char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } 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(""); } //************************************************************************************** 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=1;i<=n;i++) la[i].a=read(); for(int i=1;i<=n;i++) la[i].b=read(); for(int i=1;i<=n;i++) la[i].c=read(); sort(la+1,la+1+n,cmp); M[-inf]=inf; M[inf]=-inf; int ans=0; for(int i=n;i>=1;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
标签:
原文地址:http://www.cnblogs.com/qscqesze/p/4595758.html