3234_AC

yehongchen 2023-10-05 19:44:48 2023-10-05 19:45:17 0

//基本结构

const int N = 2510;

typedef long long int PII;

PII a[N];

int main() {

int c, l;

cin >> c >> l;

for (int i = 0; i < c; i++) {

cin >> a[i].first >> a[i].second;

} sort(a, a + c); map<int, int> spf; for (int i = 0; i < l; i++) {

int sp, cover;
cin >> sp >> cover;

spf[sp] += cover;

} int res = 0; spf[0] = spf[1001] = c; for (int i = c - 1; i >= 0; i--) {

map<int, int>::iterator t = spf.upper_bound(a[i].second);
t--;
if (t -> first >= a[i].first && t -> first <= a[i].second) {
    res++;
    t -> second--;
    if (t -> second == 0) {
        spf.erase(t);
    }

}

} cout << res << endl;

{{ vote && vote.total.up }}