#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
#define sqrt sqrtl
using namespace std;
const long long oo = 1000000000000000000;
long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen ( "sum.in", "r", stdin )
*/
vector <pair<int, int> > v;
vector <int> vv;
int mp[ 100001 ];
int a[ 100001 ], x, y, dp[ 100001 ], p[ 100001 ], d[ 100001 ], pr[ 100001 ], n, m;
void f( int o = 1, int sum = 0, int aa = 0, int b = 0 ) {
if ( o == m + 1 ) {
ans = max( ans, sum );
return;
}
for ( int i = 0; i < v.size(); i ++ ) {
if ( v[ i ].first <= a[ o ] && a[ o ] >= aa && v[ i ].second >= b && !mp[ i ] ) {
mp[ i ] = 1;
f( o + 1, sum + 1, a[ o ], v[ i ].second );
mp[ i ] = 0;
}
}
f( o + 1, sum, aa, b );
}
main () {
cin >> n;
cin >> m;
for ( int i = 1; i <= n; i ++ ) {
cin >> x >> y;
v.push_back( { x, y } );
}
for ( int i = 1; i <= m; i ++ )
cin >> a[ i ];
sort( a + 1, a + n + 1 );
f();
cout << ans;
}
/*
8 8
14 4
13 20
12 3
23 10
22 6
18 19
15 1
5 16
11
24
2
21
8
9
17
7
*/
Compilation message
joi2019_ho_t2.cpp: In function 'void f(long long int, long long int, long long int, long long int)':
joi2019_ho_t2.cpp:58:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for ( int i = 0; i < v.size(); i ++ ) {
| ~~^~~~~~~~~~
joi2019_ho_t2.cpp: At global scope:
joi2019_ho_t2.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
68 | main () {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
9 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
95 ms |
304 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
9 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
95 ms |
304 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
9 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
95 ms |
304 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |