이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5;
int n, m, S[N + 5], V[N + 5], C[N + 5], arr[N + 5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> S[i] >> V[i];
for (int i = 1; i <= m; i++) cin >> C[i];
for (int i = 1; i <= n; i++) arr[i] = i;
sort(arr + 1, arr + n + 1, [&](int a, int b) {
if (V[a] == V[b]) return S[a] < S[b];
else return V[a] < V[b];
});
sort(C + 1, C + m + 1);
int ans = 0, index = n;
for (int i = m; i >= 1; i--) {
while (index && S[arr[index]] > C[i]) index--;
if (!index) break;
if (S[arr[index]] <= C[i]) index--, ans++;
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |