Submission #139707

#TimeUsernameProblemLanguageResultExecution timeMemory
139707math0_0Exhibition (JOI19_ho_t2)C++11
100 / 100
320 ms6932 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> pl;

bool ss(pl a, pl b){
	if(a.first != b.first){
		return (a.first > b.first);
	}
	else{
		return (a.second > b.second);
	}
}

int main(){
	ll n, m;
	cin >> n >> m;
	vector<pl> pics; vector<ll> frames;
	
	for(ll one = 0; one < n; one++){
		ll s, v;
		cin >> s >> v;
		
		pics.push_back(make_pair(v, s));//prioritise value first
	}
	sort(pics.begin(), pics.end(), ss);
	//biggest value to the front
	//same value then biggest size to the front
	
	frames.push_back(0);
	for(ll one = 0; one < m; one++){
		ll s;
		cin >> s;
		frames.push_back(s);
	}
	sort(frames.begin(), frames.end());
	
	ll ans = 0, idx = m;//idx = which frame now
	for(ll one = 0; one < n; one++){
		//cout << pics[one].first << ' ' << pics[one].second << endl;
		ll csz = frames[idx];
		//largest remaining frame
		if(pics[one].second <= csz){
			ans++;
			--idx;
		}
	}
	
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...