Submission #692706

# Submission time Handle Problem Language Result Execution time Memory
692706 2023-02-02T04:39:56 Z zeroesandones Lightning Rod (NOI18_lightningrod) C++17
76 / 100
1399 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(abs(nx - x[i]) <= ny - y[i]) {
                add = false;
                break;
            } else if(abs(nx - x[i]) <= 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 1326 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 1 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 34 ms 3256 KB Output is correct
15 Correct 37 ms 3412 KB Output is correct
16 Correct 34 ms 4584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1363 ms 258316 KB Output is correct
2 Correct 1399 ms 262144 KB Output is correct
3 Correct 1380 ms 262144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1326 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -