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>
using namespace std;
#define int long long
main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
pair<int, int> p[n]; int frame[m];
for (int x = 0; x < n; x++) cin >> p[x].second >> p[x].first; //value, then size, easier
for (int x = 0; x < m; x++) cin >> frame[x];
sort(frame, frame+m, greater<int>()); //sort in decreasing size
//we will construct ans from back to front
//thus size monotonically decreases (sorted)
//and value also monotonically decreases
sort(p, p+n, greater<pair<int, int>>());
int ptr = 0, usedFrames = 0;
while (ptr != n){
//if it fits, we put it in
if (usedFrames >= m) break;
if (frame[usedFrames] >= p[ptr].second){
//can fit
usedFrames++;
ptr++;
}
else{
ptr++; //cannot fit, try next one
}
}
cout << usedFrames;
}
Compilation message (stderr)
joi2019_ho_t2.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |