Submission #175669

# Submission time Handle Problem Language Result Execution time Memory
175669 2020-01-07T09:31:33 Z cheissmart Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 100005;

pi a[N];
int c[N];
int n, m;

bool ok(int mid) {
	int lst = -1;
	set<int> s;
	for(int i = m - mid, j = 0; i < m; i++) {
		while(j < n && a[j].F <= c[i]) {
			s.insert(a[j].S);
			j++;
		}
		auto it = s.lower_bound(lst);
		if(it == s.end()) return false;
		s.erase(it);
		lst = *it;
	}
	return true;
}

signed main()
{
	
	IO_OP;
	
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> a[i].F >> a[i].S;
	sort(a, a+n);
	for(int i=0;i<m;i++)
		cin >> c[i];
	sort(c, c+m);
	int l = 0, r = m;
	while(l <= r) {
		int mid = (l + r) / 2;
		if(ok(mid)) l = mid + 1;
		else r = mid - 1;
	}
	cout << r << endl;
	
}



# 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 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -