当前位置:网站首页>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
边栏推荐
- 123456
- Golang (1) | from environmental preparation to quick start
- 递归查询多级菜单数据
- PIP install beatifulsoup4 installation failed
- Huawei fast game failed to call the login interface, and returned error code -1
- 场景化面试:关于分布式锁的十问十答
- xlrd常见操作
- 大约SQL现场“这包括”与“包括在”字符串的写法
- Some things make feelings nowhere to put
- Three components of openpyxl
猜你喜欢

华为联机对战如何提升玩家匹配成功几率

Ethereum ETH的奖励机制

Parker驱动器维修COMPAX控制器维修CPX0200H

Teach yourself to train pytorch model to Caffe (I)

Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes

xlrd常见操作

Yolov5 training custom data set (pycharm ultra detailed version)

Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)

Drawing HSV color wheel with MATLAB

MMAP learning
随机推荐
2.2.3 output of documents
854. 相似度为 K 的字符串 BFS
2.2.5 basic sentences of R language drawing
EasyExcel的读写操作
Huawei fast game failed to call the login interface, and returned error code -1
第05章_存储引擎
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
Reading and writing operations of easyexcel
EasyExcel的讀寫操作
Golang(1)|从环境准备到快速上手
如何组织一场实战攻防演练
Gcc9.5 offline installation
Parker驱动器维修COMPAX控制器维修CPX0200H
终端安全能力验证环境搭建和渗透测试记录
Making global exception handling classes with aspect
华为云ModelArts文本分类–外卖评论
DBeaver同时执行多条insert into报错处理
Simple interest mode - evil Chinese style
场景化面试:关于分布式锁的十问十答
Experienced inductance manufacturers tell you what makes the inductance noisy. Inductance noise is a common inductance fault. If the used inductance makes noise, you don't have to worry. You just need