- 2022tysc0306 的博客
差分
- 2024-8-19 19:46:22 @
#include <iostream>
#include <map>
#define ll long long
using namespace std;
int a[1000005];
map<ll, int> mp;
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i++){
ll x, y;
cin >> x >> y;
mp[x]++;
mp[y + 1]--;
}
ll last = -1, x = 0;
for(map<ll, int>::iterator it = mp.begin(); it != mp.end(); it++){
if(last != -1){
int now = it -> first;
a[x] += now - last;
}
last = it -> first;
x += it -> second;
}
for(int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;
}