Submission #594474

# Submission time Handle Problem Language Result Execution time Memory
594474 2022-07-12T13:35:04 Z Vanilla Pinball (JOI14_pinball) C++17
51 / 100
1000 ms 401980 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 1e5 + 2;
int n,m;

struct node {
    int64 v;

    node* left;
    node* right;

    node(int64 _v): v(_v) {};
    
    void extend() {
        if (left != NULL) return;
        left = new node(1e15);
        right = new node(1e15);
    }

    int64 query (int l, int r, int il, int ir) {
        if (il <= l && r <= ir) return v;
        if (l > ir || r < il) return 1e15;
        extend();
        int mid = (l + r) / 2;
        return min(left->query(l, mid, il, ir), right->query(mid + 1, r, il, ir));
    }

    void update (int l, int r, int x, int64 nval) {
        if (l == r && l == x) return void(v = min(v, nval));
        if (l > x || r < x) return;
        extend();
        int mid = (l + r) / 2;
        left->update(l, mid, x, nval);
        right->update(mid + 1, r, x, nval);
        v = min(left->v, right->v);
    }
};
 
 
int main() {
    cin >> n >> m;
    node* lf = new node(1e15);
    node* rt = new node(1e15);
    int64 rs = 1e15;
    lf->update(1, m, 1, 0);
    rt->update(1, m, m, 0);
    for (int i = 0; i < n; i++){
        int64 a,b,c,cost;
        cin >> a >> b >> c >> cost;
        int64 p1 = lf->query(1, m, a,b);
        int64 p2 = rt->query(1, m, a,b);
        rs = min(rs, p1 + p2 + cost);
        lf->update(1, m, c, p1 + cost);
        rt->update(1, m, c, p2 + cost);
    }
    cout << (rs >= 1e15 ? -1: rs);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 3 ms 1492 KB Output is correct
13 Correct 2 ms 1584 KB Output is correct
14 Correct 5 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 3 ms 1492 KB Output is correct
13 Correct 2 ms 1584 KB Output is correct
14 Correct 5 ms 1748 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 7 ms 2644 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 15 ms 5812 KB Output is correct
20 Correct 6 ms 1920 KB Output is correct
21 Correct 3 ms 1748 KB Output is correct
22 Correct 11 ms 5716 KB Output is correct
23 Correct 11 ms 6568 KB Output is correct
24 Correct 11 ms 6712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 3 ms 1492 KB Output is correct
13 Correct 2 ms 1584 KB Output is correct
14 Correct 5 ms 1748 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 7 ms 2644 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 15 ms 5812 KB Output is correct
20 Correct 6 ms 1920 KB Output is correct
21 Correct 3 ms 1748 KB Output is correct
22 Correct 11 ms 5716 KB Output is correct
23 Correct 11 ms 6568 KB Output is correct
24 Correct 11 ms 6712 KB Output is correct
25 Correct 42 ms 10300 KB Output is correct
26 Correct 181 ms 54800 KB Output is correct
27 Correct 462 ms 92904 KB Output is correct
28 Correct 331 ms 2324 KB Output is correct
29 Correct 425 ms 111440 KB Output is correct
30 Correct 445 ms 20056 KB Output is correct
31 Correct 795 ms 200920 KB Output is correct
32 Correct 696 ms 135340 KB Output is correct
33 Correct 115 ms 47000 KB Output is correct
34 Correct 460 ms 197080 KB Output is correct
35 Correct 775 ms 393036 KB Output is correct
36 Execution timed out 1060 ms 401980 KB Time limit exceeded
37 Halted 0 ms 0 KB -