#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct pic{
ll s, v;
};
ll n,m,k,x,y,z;
ll c[1005], done[1005];
pic p[1005];
int main() {
cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> p[i].s >> p[i].v;
for (int i = 1; i <= m; i++) cin >> c[i];
sort(c+1,c+1+m);
ll cur = 1e18, ans = 0;
for (int i = m; i >= 1; i--) {
ll mx = -1, pos = -1;
for (int j = 1; j <= n; j++) { //probably can become O(log N) using seg tree
if (p[j].v > mx && p[j].v <= cur && p[j].s <= c[i] && !done[j]) {
pos = j;
mx = p[j].v;
}
}
if (mx != -1) {
done[pos] = 1;
ans++;
cur = mx;
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |