# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
53872 |
2018-07-01T13:12:55 Z |
MladenP |
Pinball (JOI14_pinball) |
C++17 |
|
1000 ms |
3352 KB |
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%lld\n", x);
#define PRINT(x) fprintf(stderr, "%s = %lld\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 100010
struct SegNode{
int L, R;
lld val;
SegNode *left, *right;
SegNode() { L = R = val = 0; left = right = NULL; }
SegNode(int _L, int _R, lld _val) { L = _L, R = _R, val = _val; left = right = NULL; }
void update(int idx, lld upd) {
//printf("%d %d\n", L, R);
if(L == R) {
val = min(val, upd);
return;
}
int mid = (L+R)/2;
if(idx <= mid) {
if(left == NULL) left = new SegNode(L, mid, LINF);
left->update(idx, upd);
} else {
if(right == NULL) right = new SegNode(mid+1, R, LINF);
right->update(idx, upd);
}
val = min((left != NULL ? left->val:LINF), (right != NULL ? right->val:LINF));
}
lld sum(int l, int r) {
if(l <= L && R <= r) {
return val;
}
int mid = (L+R)/2;
lld rez = LINF;
if(L <= mid) rez = min(rez, (left == NULL ? LINF:left->sum(l, r)));
if(R > mid) rez = min(rez, (right == NULL ? LINF:right->sum(l, r)));
return rez;
}
};
lld a[MAXN], b[MAXN], c[MAXN], d[MAXN];
lld dpl[MAXN], dpr[MAXN];
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int m, n; cin >> m >> n;
SegNode* segtreeL = new SegNode(1, n, LINF);
SegNode* segtreeR = new SegNode(1, n, LINF);
segtreeL->update(1, 0);
segtreeR->update(n, 0);
lld rez = LINF;
for(int i = 1; i <= m; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
dpl[i] = segtreeL->sum(a[i], b[i]) + d[i];
dpr[i] = segtreeR->sum(a[i], b[i]) + d[i];
//PRINT(i);
//PRINT(dpl[i]);
//PRINT(dpr[i]);
rez = min(rez, dpl[i]+dpr[i]-d[i]);
segtreeL->update(c[i], dpl[i]);
segtreeR->update(c[i], dpr[i]);
}
cout << (rez == LINF ? -1:rez);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
428 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
3 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
428 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
3 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
3 ms |
692 KB |
Output is correct |
10 |
Correct |
5 ms |
712 KB |
Output is correct |
11 |
Correct |
7 ms |
836 KB |
Output is correct |
12 |
Correct |
12 ms |
1004 KB |
Output is correct |
13 |
Correct |
14 ms |
1132 KB |
Output is correct |
14 |
Correct |
15 ms |
1132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
428 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
3 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
3 ms |
692 KB |
Output is correct |
10 |
Correct |
5 ms |
712 KB |
Output is correct |
11 |
Correct |
7 ms |
836 KB |
Output is correct |
12 |
Correct |
12 ms |
1004 KB |
Output is correct |
13 |
Correct |
14 ms |
1132 KB |
Output is correct |
14 |
Correct |
15 ms |
1132 KB |
Output is correct |
15 |
Correct |
3 ms |
1132 KB |
Output is correct |
16 |
Correct |
11 ms |
1132 KB |
Output is correct |
17 |
Correct |
176 ms |
1916 KB |
Output is correct |
18 |
Correct |
15 ms |
1916 KB |
Output is correct |
19 |
Correct |
213 ms |
2428 KB |
Output is correct |
20 |
Correct |
128 ms |
2428 KB |
Output is correct |
21 |
Correct |
46 ms |
2428 KB |
Output is correct |
22 |
Correct |
281 ms |
2428 KB |
Output is correct |
23 |
Correct |
321 ms |
2584 KB |
Output is correct |
24 |
Correct |
330 ms |
2684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
428 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Correct |
3 ms |
564 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
3 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
692 KB |
Output is correct |
8 |
Correct |
2 ms |
692 KB |
Output is correct |
9 |
Correct |
3 ms |
692 KB |
Output is correct |
10 |
Correct |
5 ms |
712 KB |
Output is correct |
11 |
Correct |
7 ms |
836 KB |
Output is correct |
12 |
Correct |
12 ms |
1004 KB |
Output is correct |
13 |
Correct |
14 ms |
1132 KB |
Output is correct |
14 |
Correct |
15 ms |
1132 KB |
Output is correct |
15 |
Correct |
3 ms |
1132 KB |
Output is correct |
16 |
Correct |
11 ms |
1132 KB |
Output is correct |
17 |
Correct |
176 ms |
1916 KB |
Output is correct |
18 |
Correct |
15 ms |
1916 KB |
Output is correct |
19 |
Correct |
213 ms |
2428 KB |
Output is correct |
20 |
Correct |
128 ms |
2428 KB |
Output is correct |
21 |
Correct |
46 ms |
2428 KB |
Output is correct |
22 |
Correct |
281 ms |
2428 KB |
Output is correct |
23 |
Correct |
321 ms |
2584 KB |
Output is correct |
24 |
Correct |
330 ms |
2684 KB |
Output is correct |
25 |
Execution timed out |
1084 ms |
3352 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |