(POJ3263)最高的牛
程序员文章站
2022-03-06 11:56:02
...
题目链接:https://www.acwing.com/problem/content/103/
本题也是一个差分的简单应用。
#include"stdio.h"
#include"string.h"
#include"map"
#include"algorithm"
using namespace std;
int N,P,H,M;
int a[10010];
map <pair<int,int>,bool> Q;
int main()
{
scanf("%d%d%d%d",&N,&P,&H,&M);
for(int i = 1; i <= N; i ++)
{
int x,y;
scanf("%d%d",&x,&y);
if(x > y)
{
int t = x; x = y; y = t;
}
if(Q[make_pair(x, y)] == 1) continue;
Q[make_pair(x, y)] = 1;
a[x + 1] --;
a[y] ++;
}
for(int i = 1; i <= N;i ++)
{
a[i] = a[i] + a[i - 1];
printf("%d\n",a[i] + H);
}
}