forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE.cpp
More file actions
64 lines (54 loc) · 1.02 KB
/
E.cpp
File metadata and controls
64 lines (54 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
struct Triple
{
int x, y, z;
bool operator < (Triple u) const
{
if (x != u.x) return x > u.x;
if (y != u.y) return y > u.y;
return z > u.z;
}
};
int num, tree[200200];
void add(int x, int v)
{
for (int i = x; i <= num; i += i & -i)
tree[i] = max(tree[i], v);
}
int get(int x)
{
int res = 0;
for (int i = x; i; i -= i & -i)
res = max(res, tree[i]);
return res;
}
int main()
{
freopen("pareto.in", "r", stdin);
freopen("pareto.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
int x, y, z, n;
map <int,int> m;
cin >> n;
vector <Triple> a;
for (int i = 0; i < n; i++)
{
cin >> x >> y >> z;
a.push_back({x, y, z});
m[y] = 0;
}
num = 0;
for (auto u : m)
m[u.first] = num++;
sort(a.begin(), a.end());
int ans = 0;
for (auto u : a)
{
int y = num - m[u.y];
ans += get(y - 1) <= u.z;
add(y, u.z);
}
cout << ans << endl;
}