This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |