Submission #1118581

#TimeUsernameProblemLanguageResultExecution timeMemory
1118581cpismylifeOwOAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
193 ms18020 KiB
#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;
const int MaxN = 1e6 + 5;

bool cmp(pair<long long, long long> a, pair<long long, long long> b)
{
    if (a.first == b.first)
    {
        return a.second > b.second;
    }
    return a.first < b.first;
}

int n;
pair<long long, long long> arr[MaxN];

void Inp()
{
    cin >> n;
    for (int x = 1; x <= n; x++)
    {
        cin >> arr[x].first >> arr[x].second;
        arr[x] = make_pair(arr[x].first - arr[x].second, arr[x].first + arr[x].second);
    }
    sort(arr + 1, arr + n + 1, cmp);
}

void Exc()
{
    int res = 0;
    for (int x = 1; x <= n; x++)
    {
        int y = x;
        while (y <= n && arr[x].second >= arr[y].second)
        {
            y++;
        }
        y--;
        res++;
        x = y;
    }
    cout << res;
}

int main()
{
    //freopen("B.INP", "r", stdin);
    //freopen("B.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    //cin >> test;
    for (int x = 1; x <= test; x++)
    {
        Inp();
        Exc();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...