题解
2023-09-01 12:30:04
发布于:广东
1阅读
0回复
0点赞
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
int N, h, ans;
vector<int> height;
indexed_set cow;
indexed_set woc;
int main() {
cin>>N;
for (int i = 0; i < N; i++) {
cin>>h;
cow.insert(h);
height.push_back(h);
}
for (int i : height) {
cow.erase(i);
int le =
woc.size() -
woc.order_of_key(i);
int ri =cow.size() - cow.order_of_key(i);
woc.insert(i);
if (max(le, ri) > 2 * min(le, ri)) ans++;
}
cout<<ans;
}
这里空空如也
有帮助,赞一个