当前位置:网站首页>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
边栏推荐
- Xlrd common operations
- PIP install beatifulsoup4 installation failed
- KingbaseES V8R3集群维护案例之---在线添加备库管理节点
- 2.2.5 basic sentences of R language drawing
- EN 438-7 laminated sheet products for building covering decoration - CE certification
- Oracle HugePages没有被使用导致服务器很卡的解决方法
- matlab绘制hsv色轮图
- 华为快游戏调用登录接口失败,返回错误码 -1
- Deeply convinced plan X - network protocol basic DNS
- Objects in the list, sorted by a field
猜你喜欢

Some common processing problems of structural equation model Amos software

Reading and writing operations of easyexcel

阿里云有奖体验:用PolarDB-X搭建一个高可用系统

2.2.3 output of documents

Li Kou ----- the maximum profit of operating Ferris wheel

场景化面试:关于分布式锁的十问十答

Emotional analysis of wechat chat records on Valentine's day based on Text Mining

Uni app Bluetooth communication

Defect detection - Halcon surface scratch detection

1.2 download and installation of the help software rstudio
随机推荐
Golang(1)|从环境准备到快速上手
kingbaseES V8R3数据安全案例之---审计记录清除案例
Establishment of terminal security capability verification environment and penetration test records
Oracle检查点队列–实例崩溃恢复原理剖析
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
Efficiency difference between row first and column first traversal of mat data types in opencv
Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes
Some things make feelings nowhere to put
Some common processing problems of structural equation model Amos software
MMAP学习
Robot framework setting variables
使用Aspect制作全局异常处理类
华为快游戏调用登录接口失败,返回错误码 -1
Scenario interview: ten questions and ten answers about distributed locks
Robot operation mechanism
Yolov5 training custom data set (pycharm ultra detailed version)
MySQL InnoDB Architecture Principle
Kingbasees v8r3 data security case - audit record clearing case
JMeter installation under win7
Get JS of the previous day (timestamp conversion)