-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnestedDolls_UVA11368.cpp
63 lines (51 loc) · 1.11 KB
/
nestedDolls_UVA11368.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
#include <bits/stdc++.h>
using namespace std;
ifstream fin("nestedDolls_UVA11368.in");
ofstream fout("nestedDolls_UVA11368.out");
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()
{
int testCase; fin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
int n; fin >> n;
vector<doll> a(n);
for (int i = 0; i <= n - 1; ++i)
{
fin >> 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);
}
}
fout << s.size() << '\n';
}
return 0;
}