-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnestedDolls_UVA11368OJ.cpp
65 lines (52 loc) · 1.1 KB
/
nestedDolls_UVA11368OJ.cpp
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
65
#include <bits/stdc++.h>
using namespace std;
struct doll
{
int w;
int h;
bool operator < (const doll & temp) const
{
if (w != temp.w)
{
return w > temp.w;
}
else
{
return h < temp.h;
}
};
};
int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int testCase; cin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
int n; cin >> n;
vector<doll> a(n);
for (int i = 0; i <= n - 1; ++i)
{
cin >> a[i].w >> a[i].h;
}
sort(a.begin(), a.end());
multiset<int> s;
s.insert(INT_MAX);
for (int i = 0; i <= n - 1; ++i)
{
auto it = s.upper_bound(a[i].h);
if (it == s.end())
{
s.insert(a[i].h);
}
else
{
s.erase(it);
s.insert(a[i].h);
}
}
cout << s.size() << '\n';
}
cout.flush();
return 0;
}