제출 #1131790

#제출 시각아이디문제언어결과실행 시간메모리
1131790lopkusAdvertisement 2 (JOI23_ho_t2)C++20
59 / 100
2094 ms6512 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++) {
        cin >> a[i].first >> a[i].second;
        swap(a[i].first, a[i].second);
    }
    int ans = 0;
    vector<int> was(n + 1, 0);
    vector<int> adj[n + 1];
    sort(a.begin() + 1, a.end());
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            if(abs(a[i].second - a[j].second) <= a[i].first - a[j].first) {
                adj[i].push_back(j);
            }
        }
    }
    for(int i = n; i >= 1; i--) {
        if(was[i]) {
           continue;
        }
        was[i] = 1;
        ans += 1;
        for(auto it : adj[i]) {
            was[it] = 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...