主题链接:点击打开链接

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<queue>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 500005
#define ll int
ll n;
ll c[N], maxn;
inline ll lowbit(ll x){return x&(-x);}
void change(ll pos, ll val){
while(pos)c[pos]=max(c[pos],val), pos-=lowbit(pos);
}
ll maxx(ll pos){
ll ans = -1;
while(pos<=maxn)ans = max(ans,c[pos]),pos+=lowbit(pos);
return ans;
}
struct node{
ll b[3],num;
}w[N];
bool cmp0(node x, node y){return x.b[0]<y.b[0];}
bool cmp1(node x, node y){return x.b[1]>y.b[1];}
int main(){
ll i,j;
while(cin>>n) {
for(i=0;i<n;i++)scanf("%d",&w[i].b[0]);
for(i=0;i<n;i++)scanf("%d",&w[i].b[1]);
for(i=0;i<n;i++)scanf("%d",&w[i].b[2]);
sort(w, w+n, cmp0);
ll rank = 1;
w[0].num = 1;
for(i=1;i<n;i++) {
if(w[i].b[0]==w[i-1].b[0])w[i].num = rank;
else w[i].num = ++rank;
}
sort(w,w+n,cmp1);
for(i=1;i<=rank;i++)c[i]=-1;
maxn = rank;
i = 0;
ll ans = 0;
while(i<n) {
for(j = i; j < n && w[i].b[1] == w[j].b[1]; j++)
if(maxx(w[j].num+1)>w[j].b[2])
ans++;
for(j = i; j < n && w[i].b[1] == w[j].b[1]; j++)
change(w[j].num, w[j].b[2]);
i = j;
}
cout<<ans<<endl;
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

Codeforces 12D Ball 树形阵列模拟3排序元素的更多相关文章

  1. codeforces 12D Ball

    codeforces 12D Ball 这道题有两种做法 一种用树状数组/线段树维护区间最值,一种用map维护折线,昨天我刚遇见了一道类似的用STL维护折线的题目: 392D Three Arrays ...

  2. Codeforces 12D Ball(线段树)

    N ladies attend the ball in the King's palace. Every lady can be described with three values: beauty ...

  3. Codeforces 12D Ball cdq分治

    裸的cdq, 没啥好说的, 要注意mid左边和mid右边的a相同的情况. #include<bits/stdc++.h> #define LL long long #define fi f ...

  4. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  5. PTA数据结构与算法题目集(中文) 7-37 模拟EXCEL排序 (25 分)

    PTA数据结构与算法题目集(中文)  7-37 模拟EXCEL排序 (25 分) 7-37 模拟EXCEL排序 (25 分)   Excel可以对一组纪录按任意指定列排序.现请编写程序实现类似功能. ...

  6. 如何使用phantomJS来模拟一个HTML元素的鼠标悬停

    如何使用phantomJS来模拟一个HTML元素的鼠标悬停 (How to use phantomJS to simulate mouse hover on a HTML element) 转 htt ...

  7. Ball CodeForces - 12D (线段树)

    题目链接:https://cn.vjudge.net/problem/CodeForces-12D 题目大意:给你一个人的三个信息,如果存在一个人比当前人的这三个信息都大,那么这个人就会退出,问你最终 ...

  8. Ball CodeForces - 12D

    传送门 N ladies attend the ball in the King's palace. Every lady can be described with three values: be ...

  9. Codeforces 909 substr用法 思维合并线段目标最少 Py语句逆推DP vecrtor缩点删不同颜色点模拟 拓扑排序处理任务

    A str.substr(i,j) 从str[i]开始起取j个字符作为返回的字符串 /* Huyyt */ #include <bits/stdc++.h> using namespace ...

随机推荐

  1. 绝杀600元以下智能手机的夏新小V二代-专栏-速途网

    绝杀600元以下智能手机的夏新小V二代-专栏-速途网 绝杀600元以下智能手机的夏新小V二代

  2. Kiwi Syslog server 日志服务器搭建

    Kiwi syslog server 是一款很不错的日志服务器软件,安装过程就不多说,Linux 服务器日志由于本身就是syslog的,所以不用转换,但是windows 系统的日志格式是event形式 ...

  3. FragmentCustomAnimation实现Fragment的界面切换

    1.知识点:FragmentCustomAnimation 2.演示样例:来自于官网演示样例的简化,这样更方便于学习该知识点. 本演示样例的源代码下载地址为:http://download.csdn. ...

  4. 完美攻略心得之圣魔大战3(Castle Fantisia)艾伦希亚战记(艾伦西亚战记)包含重做版(即新艾伦希亚战记)

    (城堡幻想曲3,纠正大家个错误哦,不是圣魔大战3,圣魔大战是城堡幻想曲2,圣魔大战不是个系列,艾伦西亚战记==艾伦希亚战记,一个游戏日文名:タイトル キャッスルファンタジア -エレンシア戦記-リニュー ...

  5. 007 字符串(keep it up)

    如果你有一个isSubstring函数.能够检測一个字符串是否是还有一个字符串的子串.  给出字符串s1和s2.仅仅使用一次isSubstring就能推断s2是否是s1的旋转字符串, 请写出代码.旋转 ...

  6. duilib底层机制剖析:窗口类与窗口句柄的关联

    转载请说明原出处.谢谢~~ 看到群里朋友有人讨论WTL中的thunk技术,让我联想到了duilib的类似技术. 这些技术都是为了解决c++封装的窗口类与窗口句柄的关联问题. 这里是三篇关于thunk技 ...

  7. visual studio 2013常用快捷键 VS2013快捷键大全

    visual studio 2013常用快捷键 VS2013快捷键大全   Visual Studio 2013 是一个基本完整的开发工具集,它包括了整个软件生命周期中所需要的大部分工具,如UML工具 ...

  8. Xamarin For Visual Studio 3.7.165 完整离线破解版

    原文 Xamarin For Visual Studio 3.7.165 完整离线破解版 Xamarin For Visual Studio就是原本的Xamarin For Android 以及 Xa ...

  9. Hadoop-2.2.0中国文献——MapReduce 下一代 —配置单节点集群

    Mapreduce 包 你需从公布页面获得MapReduce tar包.若不能.你要将源代码打成tar包. $ mvn clean install -DskipTests $ cd hadoop-ma ...

  10. Unity入门

    Unity入门 用unity做一个最简单的交互.(相当于Hello World)仅仅要最后能执行就算入门了. 第一步,要先用三维制作软件制作出我们须要的场景. 这儿使用的是Max2012(软件大小3. ...