mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:48:48 +00:00
parent
c0fb0094dc
commit
a7928020ad
43
LibreOJ/10114/10114.cpp
Normal file
43
LibreOJ/10114/10114.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, x, y, val[33000], ans[16000];
|
||||
|
||||
struct node {
|
||||
int x, y;
|
||||
} t[16000];
|
||||
|
||||
int lowbit(int x) {
|
||||
return x & (-x);
|
||||
}
|
||||
|
||||
void add(int p, int v) {
|
||||
while (p <= 32001) {
|
||||
val[p] += v;
|
||||
p += lowbit(p);
|
||||
}
|
||||
}
|
||||
|
||||
int sum(int p) {
|
||||
int ans = 0;
|
||||
while (p >= 1) {
|
||||
ans += val[p];
|
||||
p -= lowbit(p);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> x >> y;
|
||||
x++, y++;
|
||||
ans[sum(x)]++;
|
||||
add(x, 1);
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
cout << ans[i] << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user