简单题。
#include <stdio.h> #define MAXN 100005 int wi[MAXN], li[MAXN];
int diff[MAXN<<]; int main() {
int n, total, max;
int i, tmp; while (scanf("%d", &n) != EOF) {
for (i=; i<n; ++i) {
scanf("%d %d", &wi[i], &li[i]);
diff[i] = diff[i+n] = wi[i]-li[i];
}
total = max = tmp = ;
for (i=; i<n+n; ++i) {
if (diff[i]>= || total+diff[i]>=) {
total += diff[i];
++tmp;
} else {
if (tmp > max)
max = tmp;
tmp = ;
total = ;
}
}
if (tmp && tmp>max)
max = tmp;
if (max > n)
max = n;
printf("%d\n", max);
} return ;
}