CometOJ 两排房子(二分)

mac2022-06-30  26

题目链接:https://cometoj.com/contest/68/problem/C?problem_id=3935 solution:

#include <bits/stdc++.h> using namespace std; int Lx[200000], Ly[200000], Rx[200000], Ry[200000]; int main() { int n, m; long long ans = 0; scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i)scanf("%d%d", &Lx[i], &Ly[i]); for (int i = 0; i < m; ++i)scanf("%d%d", &Rx[i], &Ry[i]); for (int i = 0; i < n; ++i){ ans += (upper_bound(Rx, Rx + m, Ly[i]) - Rx) - (lower_bound(Ry, Ry + m, Lx[i]) - Ry); } printf("%lld\n", ans); return 0; }
最新回复(0)