234234234

前缀和

前缀和

 

题目连接:http://www.noobdream.com/DreamJudge/Issue/page/1209/#

 

#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
const int N = 200005;

int wall[N];
int b[N],e[N];


using namespace std;

int main() {
    
    int B,E;
    while(scanf("%d%d", &B, &E) && (B || E)) {
        wall[B]++;wall[E+1]--;
    }
    for (int i = 1; i < N; i++) wall[i]+=wall[i-1];
    while(scanf("%d%d", &B, &E) && (B || E)) {
        for (int i = B; i <= E; i++)
            printf("%d\n", wall[i]);
    }
            
    
    return 0;
}

 

posted @ 2019-10-21 18:11  你若愿意,我一定去  阅读(76)  评论(0编辑  收藏  举报
23423423423