# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
330333 |
2020-11-24T19:46:34 Z |
gevacrt |
Pinball (JOI14_pinball) |
C++17 |
|
689 ms |
172672 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define int ll
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define INF 1000000000000000
#define MOD 1000000007
#define all(x) x.begin(), x.end()
class SegTree{
struct nda{
int v = INF;
nda *l = NULL, *r = NULL;
} *st;
int l, r;
void Update(nda *node, int l, int r, int L, int R, int val){
if(r < L or R < l) return;
if(L <= l and r <= R){
node->v = min(node->v, val);
return;
}
if(node->l == NULL) node->l = new nda;
if(node->r == NULL) node->r = new nda;
int m = (l+r)>>1;
Update(node->l, l, m, L, R, val);
Update(node->r, m+1, r, L, R, val);
node->v = min((node->l)->v,(node->r)->v);
return;
}
int Query(nda *node, int l, int r, int L, int R){
if(r < L or R < l) return INF;
if(L <= l and r <= R) return node->v;
int m = (l+r)>>1;
int v1 = INF, v2 = INF;
if(node->l != NULL) v1 = Query(node->l, l, m, L, R);
if(node->r != NULL) v2 = Query(node->r, m+1, r, L, R);
return min(v1,v2);
}
public:
SegTree(int l, int r){
st = new nda;
this->l = l, this->r = r;
}
void Update(int L, int R, int val){
Update(st, l, r, L, R, val);
return;
}
int Query(int L, int R){
return Query(st, l, r, L, R);
}
};
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int m, n; cin >> m >> n;
SegTree SL(1, n), SR(1, n);
SL.Update(1,1,0); SR.Update(n,n,0);
int ans = 5*INF;
while(m--){
int l, r, c, d; cin >> l >> r >> c >> d;
int k1 = SL.Query(l, r), k2 = SR.Query(l, r);
if(k1 < INF && k2 < INF) ans = min(ans, k1+d+k2);
SL.Update(c,c,k1+d); SR.Update(c,c,k2+d);
}
if(ans == 5*INF) cout << -1 << endl;
else cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
876 KB |
Output is correct |
13 |
Correct |
2 ms |
876 KB |
Output is correct |
14 |
Correct |
2 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
876 KB |
Output is correct |
13 |
Correct |
2 ms |
876 KB |
Output is correct |
14 |
Correct |
2 ms |
876 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
748 KB |
Output is correct |
17 |
Correct |
5 ms |
1900 KB |
Output is correct |
18 |
Correct |
3 ms |
492 KB |
Output is correct |
19 |
Correct |
6 ms |
2668 KB |
Output is correct |
20 |
Correct |
5 ms |
1644 KB |
Output is correct |
21 |
Correct |
2 ms |
1004 KB |
Output is correct |
22 |
Correct |
5 ms |
2540 KB |
Output is correct |
23 |
Correct |
6 ms |
2924 KB |
Output is correct |
24 |
Correct |
6 ms |
2796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
876 KB |
Output is correct |
13 |
Correct |
2 ms |
876 KB |
Output is correct |
14 |
Correct |
2 ms |
876 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
748 KB |
Output is correct |
17 |
Correct |
5 ms |
1900 KB |
Output is correct |
18 |
Correct |
3 ms |
492 KB |
Output is correct |
19 |
Correct |
6 ms |
2668 KB |
Output is correct |
20 |
Correct |
5 ms |
1644 KB |
Output is correct |
21 |
Correct |
2 ms |
1004 KB |
Output is correct |
22 |
Correct |
5 ms |
2540 KB |
Output is correct |
23 |
Correct |
6 ms |
2924 KB |
Output is correct |
24 |
Correct |
6 ms |
2796 KB |
Output is correct |
25 |
Correct |
31 ms |
7020 KB |
Output is correct |
26 |
Correct |
127 ms |
29548 KB |
Output is correct |
27 |
Correct |
383 ms |
65004 KB |
Output is correct |
28 |
Correct |
300 ms |
5868 KB |
Output is correct |
29 |
Correct |
315 ms |
66156 KB |
Output is correct |
30 |
Correct |
440 ms |
23480 KB |
Output is correct |
31 |
Correct |
647 ms |
125736 KB |
Output is correct |
32 |
Correct |
649 ms |
102380 KB |
Output is correct |
33 |
Correct |
71 ms |
23532 KB |
Output is correct |
34 |
Correct |
298 ms |
83436 KB |
Output is correct |
35 |
Correct |
445 ms |
172672 KB |
Output is correct |
36 |
Correct |
689 ms |
167276 KB |
Output is correct |
37 |
Correct |
588 ms |
167436 KB |
Output is correct |
38 |
Correct |
567 ms |
167276 KB |
Output is correct |