当前位置:网站首页>Codeforces 12D ball tree array simulation 3 sorting elements
Codeforces 12D ball tree array simulation 3 sorting elements
2022-07-05 21:43:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack
Topic links : Click to open the link
#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;
}
Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117583.html Link to the original text :https://javaforall.cn
边栏推荐
- Three components of openpyxl
- EasyExcel的读写操作
- How can Huawei online match improve the success rate of player matching
- 大约SQL现场“这包括”与“包括在”字符串的写法
- Li Kou ----- the maximum profit of operating Ferris wheel
- EasyExcel的讀寫操作
- Some common processing problems of structural equation model Amos software
- 面试官:并发编程实战会吗?(线程控制操作详解)
- matlab绘制hsv色轮图
- PIP install beatifulsoup4 installation failed
猜你喜欢
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
Deeply convinced plan X - network protocol basic DNS
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
MySQL InnoDB Architecture Principle
Two ways to realize video recording based on avfoundation
2.2.5 basic sentences of R language drawing
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Drawing HSV color wheel with MATLAB
Cold violence -- another perspective of objective function setting
2.2 basic grammar of R language
随机推荐
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
Teach yourself to train pytorch model to Caffe (2)
MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
校招期间 准备面试算法岗位 该怎么做?
Scenario interview: ten questions and ten answers about distributed locks
Recursive query of multi-level menu data
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
Zhang Lijun: penetrating uncertainty depends on four "invariants"
ESP32
What are the requirements of UL 2043 test for drive housing in the United States?
Summary of data analysis steps
Reading and writing operations of easyexcel
oracle 控制文件的多路复用
datagrid直接编辑保存“设计缺陷”
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
"Grain mall" -- Summary and induction
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
Alibaba cloud award winning experience: build a highly available system with polardb-x
[daily training -- Tencent select 50] 89 Gray code (only after seeing the solution of the problem)
Some common processing problems of structural equation model Amos software