Submission #1181245

#TimeUsernameProblemLanguageResultExecution timeMemory
1181245anteknneAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
97 ms8332 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define debug false

const int MAXN = 500 * 1000;
pii a[MAXN];
pii b[MAXN];

int main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i ++) {
        cin >> a[i].st >> a[i].nd;
    }

    for (int i = 0; i < n; i ++) {
        b[i].st = a[i].nd - a[i].st;
        b[i].nd = a[i].st + a[i].nd;
    }

    sort(b, b + n);
    reverse(b, b + n);

    int wyn = 0;
    int maks = INT_MIN;

    for (int i = 0; i < n; i ++) {
        if (b[i].nd > maks) {
            wyn ++;
            maks = b[i].nd;
        }
    }

    cout << wyn << "\n";



    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...