Submission #317905

# Submission time Handle Problem Language Result Execution time Memory
317905 2020-10-30T18:40:39 Z Gilgamesh Exhibition (JOI19_ho_t2) C++17
100 / 100
66 ms 4480 KB
#include <bits/stdc++.h>
//#include <bits/extc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

//const int MOD = 1e9 + 7;
const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){ //(a + b) % 1e9 + 7
    a += b;
    if(a < 0){
    	a += MOD;
    }
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

bool comp(pii a, pii b){
	return a.y == b.y ? a.x < b.x : a.y < b.y;
}

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    int n, m; cin >> n >> m;
    pii pics[n];
    int frames[m];
    int mnsz = 1e9 + 1;
    for(int i = 0; i < n; ++i){
    	cin >> pics[i].x >> pics[i].y;
    	mnsz = min(mnsz, pics[i].x);
    }
    int mx = 0;
    for(int i = 0; i < m; ++i){
    	cin >> frames[i];
    	mx = max(mx, frames[i]);
    }
    if(mx < mnsz){
    	cout << "0\n";
    	return 0;
    }
    sort(frames, frames + m);
    sort(pics, pics + n, comp);
    int l = 1, r = m;
    while(l < r){
    	int mid = l + (r - l + 1) / 2;
    	int p1 = 0, p2 = m - mid;
    	while(p1 < n && p2 < m){
    		if(pics[p1].x <= frames[p2]){
    			++p1; ++p2;
    		}
    		else{
    			++p1;
    		}
    	}
    	if(p2 == m){
    		l = mid;
    	}
    	else{
    		r = mid - 1;
    	}
    }
    cout << l << "\n";
    //CHECK FOR LONG LONG!!!
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 57 ms 4344 KB Output is correct
39 Correct 53 ms 4480 KB Output is correct
40 Correct 49 ms 4472 KB Output is correct
41 Correct 57 ms 4472 KB Output is correct
42 Correct 56 ms 4376 KB Output is correct
43 Correct 63 ms 4472 KB Output is correct
44 Correct 57 ms 4476 KB Output is correct
45 Correct 57 ms 4344 KB Output is correct
46 Correct 56 ms 4472 KB Output is correct
47 Correct 52 ms 3960 KB Output is correct
48 Correct 49 ms 3960 KB Output is correct
49 Correct 46 ms 3840 KB Output is correct
50 Correct 44 ms 3584 KB Output is correct
51 Correct 36 ms 4352 KB Output is correct
52 Correct 55 ms 4352 KB Output is correct
53 Correct 57 ms 4348 KB Output is correct
54 Correct 49 ms 4344 KB Output is correct
55 Correct 56 ms 4344 KB Output is correct
56 Correct 36 ms 3072 KB Output is correct
57 Correct 20 ms 1664 KB Output is correct
58 Correct 34 ms 3072 KB Output is correct
59 Correct 36 ms 3200 KB Output is correct
60 Correct 20 ms 1664 KB Output is correct
61 Correct 33 ms 2560 KB Output is correct
62 Correct 62 ms 4352 KB Output is correct
63 Correct 62 ms 4352 KB Output is correct
64 Correct 61 ms 4472 KB Output is correct
65 Correct 63 ms 4472 KB Output is correct
66 Correct 61 ms 4352 KB Output is correct
67 Correct 65 ms 4344 KB Output is correct
68 Correct 66 ms 4344 KB Output is correct
69 Correct 62 ms 4344 KB Output is correct
70 Correct 59 ms 4344 KB Output is correct
71 Correct 60 ms 4352 KB Output is correct
72 Correct 57 ms 4344 KB Output is correct
73 Correct 59 ms 4344 KB Output is correct