이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |