D - online games
题解
code:
#include#define ll long long using namespace std; const int maxn = 2e5 + 9; int ans[maxn]; void work() { int n;cin >> n; int a, b; vector > v; int cnt = 0; for(int i = 1; i <= n; ++i) { cin >> a >> b; v.push_back({a, 1}); v.push_back({a + b, -1}); } sort(v.begin(), v.end()); for(int i = 0; i < v.size() - 1; ++i) { cnt += v[i].second; ans[cnt] += (v[i + 1].first - v[i].first); } for(int i = 1; i <= n; ++i) cout << ans[i] << " "; } int main() { ios::sync_with_stdio(0); work(); return 0; }



