Submission #692710

# Submission time Handle Problem Language Result Execution time Memory
692710 2023-02-02T04:42:24 Z zeroesandones Lightning Rod (NOI18_lightningrod) C++17
76 / 100
1458 ms 262144 KB
#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];
    }

    stack<pi> s;
    for(int i = 0; i < n; ++i) {
        bool add = true;
        while(!s.empty()) {
            auto [nx, ny] = s.top();
            if(x[i] - nx <= ny - y[i]) {
                add = false;
                break;
            }

            if(x[i] - nx <= y[i] - ny)
                s.pop();
            else
                break;
        }
        if(add)
            s.push({x[i], y[i]});
    }

    cout << s.size() << nl;
}

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

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1347 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 280 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 280 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 280 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 0 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 280 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 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 0 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 340 KB Output is correct
14 Correct 35 ms 3428 KB Output is correct
15 Correct 39 ms 3696 KB Output is correct
16 Correct 42 ms 4732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1369 ms 258216 KB Output is correct
2 Correct 1426 ms 262144 KB Output is correct
3 Correct 1458 ms 262144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1347 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -