Submission #895927

#TimeUsernameProblemLanguageResultExecution timeMemory
895927niterAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
136 ms14180 KiB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }

const int mxn = (int)(5e5) + 10;
const int INF = (int)(2e9) + 10;
pii a[mxn];

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    loop(i,0,n){
        int x, y;
        cin >> x >> y;
        a[i] = {x + y, y - x};
    }
    sort(a, a + n, greater<pii>());
//    loop(i,0,n){
//        cerr << a[i] << endl;
//    }
    int y_lim = -INF, ans = 0;
    loop(i,0,n){
        if(a[i].ss > y_lim){
            y_lim = a[i].ss;
            ans++;
        }
    }
    cout << ans << '\n';
}
/*
9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
*/

Compilation message (stderr)

Main.cpp: In function 'std::ostream& operator<<(std::ostream&, std::pair<int, int>)':
Main.cpp:16:84: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
      |                                                                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...