Submission #129436

# Submission time Handle Problem Language Result Execution time Memory
129436 2019-07-12T08:47:31 Z shuvi_dola Exhibition (JOI19_ho_t2) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+4;
int fr[N];
int n, m;
struct pic
{
	int sz, v;
}	a[N];
bool cmp(pic a, pic b)
{
	if(a.v == b.v)
		return a.sz > b.sz;
	return a.v > b.v;
}
bool ck(int len)
{
	int j = m;
	for(int i=1;i<=n;i++)
	{
		// cout<<a[i].sz<<' '<<fr[j]<<'\n';
		if(a[i].sz <= fr[j])
		{
			j--;
			if(j == m-len)
				return true;
		}
	}
	
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].sz>>a[i].v;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>fr[i];
	}
	// cout<<fr[1]<<' '<<fr[2];
	sort(a+1,a+1+n,cmp);
	sort(fr+1,fr+1+m);
	// cout<<ck(2);
	int L = 0, R = min(n, m), res = 0;
	while(L <= R)
	{
		int mid = (L+R)/2;
		// cout<<mid<<'\n';
		// cout<<L<<' '<<R<<' '<<mid<<'\n';
		if(ck(mid) == true)
		{
			res = max(res ,mid);
			L = mid+1;
		}
		else
			R = mid-1;
	}
	cout<<res;
}
# 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 Incorrect 2 ms 376 KB Output isn't correct
5 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 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 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 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -