http://acm.hdu.edu.cn/showproblem.php?pid=1556
View Code
//区间标记, 当然对于任意修改都能做 const int MM = 111111; #define debug puts("wrong") const double lep=1e-10; int N,num[MM]; void solve() { int i,j,k,x,y; memset(num,0,sizeof(num)); for(i=0;i<N;i++) { scanf("%d%d",&x,&y); num[x]++, num[y+1]--; } int ans=num[1]; printf("%d",ans); for(i=2;i<=N;i++) { ans+=num[i]; printf(" %d",ans); } printf("\n"); } int main() { while(scanf("%d",&N),N) solve(); return 0; }