怎么选到了这么水的题...
/* Telekinetic Forest Guard */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 10005; int n; struct _data { int l, r; bool operator < (const _data &x) const { return r != x.r ? r < x.r : l < x.l; } } line[maxn]; inline int iread() { int f = 1, x = 0; char ch = getchar(); for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1; for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return f * x; } int main() { n = iread(); for(int i = 1; i <= n; i++) line[i].l = iread(), line[i].r = line[i].l + iread(); sort(line + 1, line + 1 + n); int ans = 0; for(int i = 1, now = 0; i <= n; i++) if(now <= line[i].l) ans++, now = line[i].r; printf("%d\n", ans); return 0; }