Submission #1261365

#TimeUsernameProblemLanguageResultExecution timeMemory
1261365tvgkAdvertisement 2 (JOI23_ho_t2)C++20
0 / 100
25 ms2372 KiB
#include<bits/stdc++.h>
using namespace std;
#define task "a"
#define se second
#define fi first
#define ll long long
#define ii pair<ll, ll>
const long mxN = 5e5 + 7, inf = 1e9 + 7;

int n;
ii a[mxN];

bool cmp(ii u, ii v)
{
    return u.fi < v.fi || (u.fi == v.fi && u.se > v.se);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(task".INP", "r", stdin);
    //freopen(task".OUT", "w", stdout);

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].fi >> a[i].se;
        a[i].fi -= a[i].se;
        a[i].se = a[i].fi + 2 * a[i].se;
    }
    sort(a + 1, a + n + 1, cmp);

    int ans = 0, v = 0;
    for (int i = 2; i <= n; i++)
    {
        if (a[i].se > v)
        {
            ans++;
            v = a[i].se;
        }
    }
    cout << ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...