杭电OJ 1156(C++)
#include <iostream> #include <algorithm> #include <vector> using namespace std; const int MAXN = 200002; int l[MAXN], r[MAXN]; //垂线左侧的点,垂线右侧的点 int y[MAXN]; //y轴坐标 int n, w; struct Line //垂直于x轴的直线 { int x, y; friend bool operator < (Line a, Line b) { return a.x < b.x; } }line[MAXN]; int lowbit(int x) { return x & -x; } void add(int t[], int x, int v) { while (x <= w) { t[x] += v; x += lowbit(x); } } int sum(int t[], int x) { int res = 0; while (x > 0) { res += t[x]; x -= lowbit(x); } return res; } int main(void) { while (cin >> n) { if (n == 0) break; for (int i = 0; i < n; i++) { cin >> line[i