/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e5 + 10;
struct picture
{
int s, v;
}p[maxn];
bool cmp(picture p1, picture p2)
{
if (p1.v < p2.v)
return true;
if (p1.v > p2.v)
return false;
return p1.s < p2.s;
}
int n, m, c[maxn], used[maxn], dp[maxn];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
{
cin >> p[i].s >> p[i].v;
}
for (int i = 1; i <= m; i ++)
cin >> c[i];
sort(c + 1, c + m + 1);
sort(p + 1, p + n + 1, cmp);
///cout << check(2) << endl;
///return;
int ans = 0;
c[m + 1] = 1e9 + 10;
for (int i = n; i > 0; i --)
{
int mx = ans;
int lf = 0, rf = ans + 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (c[m - mf + 1] < p[i].s)
rf = mf - 1;
else
lf = mf + 1;
}
dp[i] = rf;
ans = max(ans, dp[i]);
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
/**
10 10
978749728 144544247
765886828 382970504
724321206 775440108
793469869 329793955
744661733 757784475
737531928 772848949
880702330 298220471
886356598 234769581
756489712 541017091
976784156 205683907
498207927
462526472
688444509
591128229
744661733
421432475
299894333
737531928
39584784
724321206
*/
Compilation message
joi2019_ho_t2.cpp: In function 'void solve()':
joi2019_ho_t2.cpp:62:17: warning: unused variable 'mx' [-Wunused-variable]
62 | int mx = ans;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
2 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
2 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
2 ms |
212 KB |
Output is correct |
37 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
2 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
212 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
2 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
2 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
2 ms |
212 KB |
Output is correct |
37 |
Correct |
2 ms |
212 KB |
Output is correct |
38 |
Correct |
127 ms |
1756 KB |
Output is correct |
39 |
Correct |
130 ms |
1752 KB |
Output is correct |
40 |
Correct |
116 ms |
1768 KB |
Output is correct |
41 |
Correct |
129 ms |
1896 KB |
Output is correct |
42 |
Correct |
125 ms |
1748 KB |
Output is correct |
43 |
Correct |
129 ms |
1748 KB |
Output is correct |
44 |
Correct |
124 ms |
1844 KB |
Output is correct |
45 |
Correct |
122 ms |
1740 KB |
Output is correct |
46 |
Correct |
121 ms |
1844 KB |
Output is correct |
47 |
Correct |
114 ms |
1664 KB |
Output is correct |
48 |
Correct |
112 ms |
1616 KB |
Output is correct |
49 |
Correct |
99 ms |
1484 KB |
Output is correct |
50 |
Correct |
98 ms |
1472 KB |
Output is correct |
51 |
Correct |
124 ms |
1740 KB |
Output is correct |
52 |
Correct |
124 ms |
1748 KB |
Output is correct |
53 |
Correct |
123 ms |
1740 KB |
Output is correct |
54 |
Correct |
124 ms |
1844 KB |
Output is correct |
55 |
Correct |
134 ms |
1848 KB |
Output is correct |
56 |
Correct |
81 ms |
1456 KB |
Output is correct |
57 |
Correct |
47 ms |
588 KB |
Output is correct |
58 |
Correct |
93 ms |
1464 KB |
Output is correct |
59 |
Correct |
88 ms |
1392 KB |
Output is correct |
60 |
Correct |
42 ms |
616 KB |
Output is correct |
61 |
Correct |
72 ms |
1080 KB |
Output is correct |
62 |
Correct |
129 ms |
1768 KB |
Output is correct |
63 |
Correct |
128 ms |
1788 KB |
Output is correct |
64 |
Correct |
125 ms |
1744 KB |
Output is correct |
65 |
Correct |
129 ms |
1856 KB |
Output is correct |
66 |
Correct |
138 ms |
1832 KB |
Output is correct |
67 |
Correct |
151 ms |
1748 KB |
Output is correct |
68 |
Correct |
138 ms |
1776 KB |
Output is correct |
69 |
Correct |
134 ms |
1820 KB |
Output is correct |
70 |
Correct |
132 ms |
1740 KB |
Output is correct |
71 |
Correct |
131 ms |
1852 KB |
Output is correct |
72 |
Correct |
132 ms |
1748 KB |
Output is correct |
73 |
Correct |
126 ms |
1844 KB |
Output is correct |