#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using ii = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;
// pairs
#define mp make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (a)-1; i >= (b); --i)
#define R0F(i,a) ROF(i,a,0)
#define trav(a,x) for (auto& a: x)
#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
vector<pair<ll, ll>> pics;
vector<ll> frames;
int main(){
std::ios::sync_with_stdio(false); cin.tie(NULL);
ll N, M; cin >> N >> M;
F0R(_, N){
ll s, v; cin >> s >> v; pics.pb({s,v});
}
F0R(_, M){
ll c; cin >> c; frames.pb(c);
}
sort(all(frames), [](ll& n1, ll& n2)->bool{return n1 > n2;}); // bigger is better
sort(all(pics), [](pair<ll,ll>&p1, pair<ll,ll>&p2)->bool{
if (p1.s == p2.s) { return p1.f > p2.f;} return p1.s > p2.s;
});
//trav(i, pics) cout << i.f << " " << i.s << " ";
//cout << endl;
ll cur_frame = 0;
trav(pic, pics){
if (pic.f <= frames[cur_frame]){
cur_frame++;
}
}
cout << min(N,min(cur_frame,M)) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 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 |
0 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 |
212 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 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 |
0 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 |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 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 |
0 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 |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
340 KB |
Output is correct |
38 |
Correct |
36 ms |
3696 KB |
Output is correct |
39 |
Correct |
37 ms |
3660 KB |
Output is correct |
40 |
Correct |
32 ms |
3664 KB |
Output is correct |
41 |
Correct |
37 ms |
3692 KB |
Output is correct |
42 |
Correct |
36 ms |
3600 KB |
Output is correct |
43 |
Correct |
36 ms |
3680 KB |
Output is correct |
44 |
Correct |
39 ms |
3696 KB |
Output is correct |
45 |
Correct |
36 ms |
3684 KB |
Output is correct |
46 |
Correct |
47 ms |
3600 KB |
Output is correct |
47 |
Correct |
37 ms |
3460 KB |
Output is correct |
48 |
Correct |
46 ms |
3444 KB |
Output is correct |
49 |
Correct |
29 ms |
3180 KB |
Output is correct |
50 |
Correct |
30 ms |
3224 KB |
Output is correct |
51 |
Correct |
39 ms |
3636 KB |
Output is correct |
52 |
Correct |
36 ms |
3588 KB |
Output is correct |
53 |
Correct |
38 ms |
3656 KB |
Output is correct |
54 |
Correct |
31 ms |
3600 KB |
Output is correct |
55 |
Correct |
37 ms |
3652 KB |
Output is correct |
56 |
Correct |
24 ms |
2560 KB |
Output is correct |
57 |
Correct |
15 ms |
1492 KB |
Output is correct |
58 |
Correct |
23 ms |
2512 KB |
Output is correct |
59 |
Correct |
24 ms |
3976 KB |
Output is correct |
60 |
Correct |
15 ms |
2280 KB |
Output is correct |
61 |
Correct |
30 ms |
3884 KB |
Output is correct |
62 |
Correct |
39 ms |
6592 KB |
Output is correct |
63 |
Correct |
37 ms |
6592 KB |
Output is correct |
64 |
Correct |
40 ms |
6524 KB |
Output is correct |
65 |
Correct |
38 ms |
6592 KB |
Output is correct |
66 |
Correct |
44 ms |
6528 KB |
Output is correct |
67 |
Correct |
38 ms |
6592 KB |
Output is correct |
68 |
Correct |
40 ms |
6544 KB |
Output is correct |
69 |
Correct |
42 ms |
6516 KB |
Output is correct |
70 |
Correct |
47 ms |
6480 KB |
Output is correct |
71 |
Correct |
39 ms |
6508 KB |
Output is correct |
72 |
Correct |
39 ms |
6604 KB |
Output is correct |
73 |
Correct |
39 ms |
6620 KB |
Output is correct |