제출 #692678

#제출 시각아이디문제언어결과실행 시간메모리
692678zeroesandonesLightning Rod (NOI18_lightningrod)C++17
40 / 100
2076 ms262144 KiB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "

#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back

void solve()
{
    ll n;
    cin >> n;

    ll x[n], y[n];
    FOR(i, 0, n) {
        cin >> x[i] >> y[i];
    }

    vector<array<ll, 3>> a(n);
    for(int i = 0; i < n; ++i) {
        a[i] = {x[i], y[i], i};
    }

    sort(all(a), [&](array<ll, 3> lhs, array<ll, 3> rhs) {
        return lhs[1] > rhs[1];
            });

    ll ans = 0;
    bool covered[n] = {};
    for(int i = 0; i < n; ++i) {
        if(covered[a[i][2]]) continue;
        covered[a[i][2]] = true;
        ++ans;
        for(int j = a[i][2] - 1; j >= 0; --j) {
            if(abs(a[i][0] - x[j]) <= a[i][1] - y[j]) {
                covered[j] = true;
            }
        }
        for(int j = a[i][2] + 1; j < n; ++j) {
            if(abs(a[i][0] - x[j]) <= a[i][1] - y[j]) {
                covered[j] = true;
            }
        }
    }

    cout << ans << nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...