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