Submission #692890

# Submission time Handle Problem Language Result Execution time Memory
692890 2023-02-02T06:59:22 Z saayan007 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1695 ms 250376 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define fur(i, a, b) for(ll i = a; i <= (ll) b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll) b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define nl "\n"

const ll inf = 1e12L;

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

    ll n;
    cin >> n;

    pl a[n + 2];
#define x first
#define y second
    fur(i, 1, n) {
        cin >> a[i].x >> a[i].y;
    }
    a[0] = a[n + 1] = {0, 0};
    // sort(a + 1, a + n + 1);

    bool under[n + 1] = {};
    ll mx = -inf;
    ruf(i, n, 1) {
        if(a[i].y - a[i].x <= mx) {
            under[i] = 1;
        } else {
            mx = a[i].y - a[i].x;
        }
    }

    mx = -inf;
    fur(i, 1, n) {
        if(a[i].y + a[i].x <= mx) {
            under[i] = 1;
        } else {
            mx = a[i].y + a[i].x;
        }
    }

    ll ans = n;
    fur(i, 1, n) {
        if(under[i])
            --ans;
    }
    cout << ans <<nl;
}
# Verdict Execution time Memory Grader output
1 Correct 1359 ms 161580 KB Output is correct
2 Correct 1293 ms 161036 KB Output is correct
3 Correct 1282 ms 156668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 428 KB Output is correct
14 Correct 36 ms 3320 KB Output is correct
15 Correct 40 ms 3476 KB Output is correct
16 Correct 34 ms 3304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1388 ms 165956 KB Output is correct
2 Correct 1357 ms 165844 KB Output is correct
3 Correct 1316 ms 161856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1359 ms 161580 KB Output is correct
2 Correct 1293 ms 161036 KB Output is correct
3 Correct 1282 ms 156668 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 36 ms 3320 KB Output is correct
18 Correct 40 ms 3476 KB Output is correct
19 Correct 34 ms 3304 KB Output is correct
20 Correct 1388 ms 165956 KB Output is correct
21 Correct 1357 ms 165844 KB Output is correct
22 Correct 1316 ms 161856 KB Output is correct
23 Correct 1689 ms 183404 KB Output is correct
24 Correct 1637 ms 152268 KB Output is correct
25 Correct 1695 ms 250376 KB Output is correct