제출 #1131810

#제출 시각아이디문제언어결과실행 시간메모리
1131810lopkusAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
102 ms8264 KiB
#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int,int>> a(n + 1);
    for(int i = 1; i <= n; i++) {
        int u, v;
        cin >> u >> v;
        a[i] = {u - v, u + v};
    }
    sort(a.begin() + 1, a.end(), [&](pair<int, int> x, pair<int, int> y) {
  		if (x.first == y.first)
  			return x.second > y.second;
  		return x.first < y.first;
  	});
    int ans = 0, best = - 1;
    for(int i = 1; i <= n; i++) {
        if(best < a[i].second) {
            best = a[i].second;
            ans += 1;
        }
    }
    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...