#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define db 0
#define EPS (1e-7) //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,m;
pi A[MAXN]; // (val, size)
ll B[MAXN];
struct node {
int s,e,m;
ll v;
node *l,*r;
node(ll _S,ll _E){
s=_S,e=_E,m=(s+e)>>1;
v=0;
if(s^e){
l=new node(s,m);
r=new node(m+1,e);
v=min(l->v,r->v);
} else v=A[s].s,l=r=0;
}
ll rmq(ll x,ll y,ll limit) {
//~ for(ll i=y;i>=x;--i) {
//~ if(A[i].s<=l) return i;
//~ }
//~ return x-1;
if(v>limit) return x-1;
if(s==e) return s;
if(s==x&&e==y) {
if(r->v <= limit) return r->rmq(m+1,y,limit);
else return l->rmq(x,m,limit);
} else if(x>m) {
return r->rmq(x,y,limit);
} else if(y<=m) {
return l->rmq(x,y,limit);
} else {
ll lol=r->rmq(m+1,y,limit);
if(lol<m+1) return l->rmq(x,m,limit);
else return lol;
}
}
}*seg;
int main()
{
FAST
cin>>n>>m;
FOR(i,0,n) {
cin>>A[i].s>>A[i].f;
}
FOR(i,0,m) cin>>B[i];
sort(B,B+m);sort(A,A+n);seg=new node(0,n-1);
ll pa=n-1; for(ll i=m-1;i>=0;--i) {
if(pa<0) { cout<<m-i-1<<'\n'; return 0; }
ll ind=seg->rmq(0,pa,B[i]);
if(~ind) {
pa=ind-1;
} else {
cout<<m-i-1<<'\n'; return 0;
}
}
cout<<m<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
504 KB |
Output is correct |
21 |
Correct |
3 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
476 KB |
Output is correct |
26 |
Correct |
3 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
28 |
Correct |
3 ms |
508 KB |
Output is correct |
29 |
Correct |
3 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
31 |
Correct |
3 ms |
504 KB |
Output is correct |
32 |
Correct |
2 ms |
504 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
504 KB |
Output is correct |
35 |
Correct |
2 ms |
380 KB |
Output is correct |
36 |
Correct |
3 ms |
476 KB |
Output is correct |
37 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
504 KB |
Output is correct |
21 |
Correct |
3 ms |
504 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
3 ms |
504 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
476 KB |
Output is correct |
26 |
Correct |
3 ms |
504 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
28 |
Correct |
3 ms |
508 KB |
Output is correct |
29 |
Correct |
3 ms |
504 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
31 |
Correct |
3 ms |
504 KB |
Output is correct |
32 |
Correct |
2 ms |
504 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
504 KB |
Output is correct |
35 |
Correct |
2 ms |
380 KB |
Output is correct |
36 |
Correct |
3 ms |
476 KB |
Output is correct |
37 |
Correct |
3 ms |
504 KB |
Output is correct |
38 |
Correct |
88 ms |
14988 KB |
Output is correct |
39 |
Correct |
86 ms |
14968 KB |
Output is correct |
40 |
Correct |
82 ms |
15096 KB |
Output is correct |
41 |
Correct |
88 ms |
15068 KB |
Output is correct |
42 |
Correct |
75 ms |
14940 KB |
Output is correct |
43 |
Correct |
76 ms |
14968 KB |
Output is correct |
44 |
Correct |
81 ms |
14940 KB |
Output is correct |
45 |
Correct |
88 ms |
14968 KB |
Output is correct |
46 |
Correct |
88 ms |
15016 KB |
Output is correct |
47 |
Correct |
79 ms |
14480 KB |
Output is correct |
48 |
Correct |
78 ms |
14456 KB |
Output is correct |
49 |
Correct |
69 ms |
11132 KB |
Output is correct |
50 |
Correct |
70 ms |
11128 KB |
Output is correct |
51 |
Correct |
76 ms |
14976 KB |
Output is correct |
52 |
Correct |
75 ms |
14968 KB |
Output is correct |
53 |
Correct |
75 ms |
14928 KB |
Output is correct |
54 |
Correct |
81 ms |
15088 KB |
Output is correct |
55 |
Correct |
88 ms |
14968 KB |
Output is correct |
56 |
Correct |
53 ms |
13304 KB |
Output is correct |
57 |
Correct |
25 ms |
2108 KB |
Output is correct |
58 |
Correct |
52 ms |
13176 KB |
Output is correct |
59 |
Correct |
53 ms |
13304 KB |
Output is correct |
60 |
Correct |
25 ms |
2168 KB |
Output is correct |
61 |
Correct |
82 ms |
6572 KB |
Output is correct |
62 |
Correct |
83 ms |
14968 KB |
Output is correct |
63 |
Correct |
84 ms |
14968 KB |
Output is correct |
64 |
Correct |
93 ms |
14964 KB |
Output is correct |
65 |
Correct |
85 ms |
15076 KB |
Output is correct |
66 |
Correct |
83 ms |
14968 KB |
Output is correct |
67 |
Correct |
84 ms |
14968 KB |
Output is correct |
68 |
Correct |
84 ms |
15096 KB |
Output is correct |
69 |
Correct |
87 ms |
14968 KB |
Output is correct |
70 |
Correct |
85 ms |
14968 KB |
Output is correct |
71 |
Correct |
83 ms |
14968 KB |
Output is correct |
72 |
Correct |
85 ms |
15012 KB |
Output is correct |
73 |
Correct |
81 ms |
14968 KB |
Output is correct |