#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5;
int n, d;
pair <int, pair <int, int> > a[N];
double mx(double f) {
double cur = f, now = 0;
for (int i = 1; i <= n; ++i) {
if (cur >= a[i].first - now) {
cur -= a[i].first - now;
now = a[i].first;
}
else
return now + cur;
if (f <= a[i].second.second)
cur += a[i].second.first;
}
return min(d * 1.0, now + cur);
}
int main() {
ios :: sync_with_stdio(0), cin.tie(0);
cin >> n >> d;
for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second.first >> a[i].second.second;
sort(a + 1, a + 1 + n);
int bruh = 0;
while (mx(bruh) != d) ++bruh;
cout << bruh;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
2757 ms |
304 KB |
Output is correct |
4 |
Correct |
6 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
2528 ms |
336 KB |
Output is correct |
9 |
Correct |
2446 ms |
308 KB |
Output is correct |
10 |
Correct |
2584 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
603 ms |
324 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
123 ms |
3744 KB |
Output is correct |
2 |
Correct |
149 ms |
3832 KB |
Output is correct |
3 |
Correct |
128 ms |
3788 KB |
Output is correct |
4 |
Correct |
119 ms |
3808 KB |
Output is correct |
5 |
Correct |
120 ms |
3932 KB |
Output is correct |
6 |
Correct |
124 ms |
3800 KB |
Output is correct |
7 |
Correct |
117 ms |
3832 KB |
Output is correct |
8 |
Correct |
117 ms |
3828 KB |
Output is correct |
9 |
Correct |
120 ms |
3840 KB |
Output is correct |
10 |
Correct |
118 ms |
3828 KB |
Output is correct |
11 |
Correct |
115 ms |
3820 KB |
Output is correct |
12 |
Correct |
121 ms |
3808 KB |
Output is correct |
13 |
Correct |
118 ms |
3832 KB |
Output is correct |
14 |
Correct |
123 ms |
3948 KB |
Output is correct |
15 |
Correct |
143 ms |
3744 KB |
Output is correct |
16 |
Correct |
121 ms |
3828 KB |
Output is correct |
17 |
Correct |
119 ms |
3744 KB |
Output is correct |
18 |
Correct |
128 ms |
3768 KB |
Output is correct |
19 |
Correct |
130 ms |
3912 KB |
Output is correct |
20 |
Correct |
117 ms |
3764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
468 KB |
Output is correct |
4 |
Correct |
4 ms |
544 KB |
Output is correct |
5 |
Correct |
4 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
4 ms |
568 KB |
Output is correct |
15 |
Correct |
6 ms |
476 KB |
Output is correct |
16 |
Correct |
17 ms |
468 KB |
Output is correct |
17 |
Correct |
31 ms |
468 KB |
Output is correct |
18 |
Correct |
38 ms |
596 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
568 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
4 ms |
468 KB |
Output is correct |
24 |
Correct |
4 ms |
552 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
468 KB |
Output is correct |
4 |
Correct |
4 ms |
544 KB |
Output is correct |
5 |
Correct |
4 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
4 ms |
568 KB |
Output is correct |
15 |
Correct |
6 ms |
476 KB |
Output is correct |
16 |
Correct |
17 ms |
468 KB |
Output is correct |
17 |
Correct |
31 ms |
468 KB |
Output is correct |
18 |
Correct |
38 ms |
596 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
568 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
4 ms |
468 KB |
Output is correct |
24 |
Correct |
4 ms |
552 KB |
Output is correct |
25 |
Correct |
4 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
94 ms |
5956 KB |
Output is correct |
28 |
Correct |
99 ms |
5936 KB |
Output is correct |
29 |
Correct |
94 ms |
5972 KB |
Output is correct |
30 |
Correct |
91 ms |
5944 KB |
Output is correct |
31 |
Correct |
91 ms |
5860 KB |
Output is correct |
32 |
Correct |
96 ms |
5916 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
324 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
96 ms |
5956 KB |
Output is correct |
40 |
Correct |
109 ms |
5880 KB |
Output is correct |
41 |
Correct |
140 ms |
5944 KB |
Output is correct |
42 |
Correct |
99 ms |
5964 KB |
Output is correct |
43 |
Correct |
1006 ms |
5972 KB |
Output is correct |
44 |
Correct |
1575 ms |
6004 KB |
Output is correct |
45 |
Execution timed out |
3055 ms |
7244 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
2757 ms |
304 KB |
Output is correct |
4 |
Correct |
6 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
2528 ms |
336 KB |
Output is correct |
9 |
Correct |
2446 ms |
308 KB |
Output is correct |
10 |
Correct |
2584 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
603 ms |
324 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
5 ms |
212 KB |
Output is correct |
18 |
Execution timed out |
3072 ms |
212 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
2757 ms |
304 KB |
Output is correct |
4 |
Correct |
6 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
2528 ms |
336 KB |
Output is correct |
9 |
Correct |
2446 ms |
308 KB |
Output is correct |
10 |
Correct |
2584 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
603 ms |
324 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
468 KB |
Output is correct |
19 |
Correct |
4 ms |
544 KB |
Output is correct |
20 |
Correct |
4 ms |
528 KB |
Output is correct |
21 |
Correct |
4 ms |
464 KB |
Output is correct |
22 |
Correct |
4 ms |
464 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
328 KB |
Output is correct |
28 |
Correct |
1 ms |
328 KB |
Output is correct |
29 |
Correct |
4 ms |
568 KB |
Output is correct |
30 |
Correct |
6 ms |
476 KB |
Output is correct |
31 |
Correct |
17 ms |
468 KB |
Output is correct |
32 |
Correct |
31 ms |
468 KB |
Output is correct |
33 |
Correct |
38 ms |
596 KB |
Output is correct |
34 |
Correct |
4 ms |
468 KB |
Output is correct |
35 |
Correct |
6 ms |
596 KB |
Output is correct |
36 |
Correct |
4 ms |
568 KB |
Output is correct |
37 |
Correct |
4 ms |
468 KB |
Output is correct |
38 |
Correct |
4 ms |
468 KB |
Output is correct |
39 |
Correct |
4 ms |
552 KB |
Output is correct |
40 |
Correct |
4 ms |
468 KB |
Output is correct |
41 |
Correct |
15 ms |
212 KB |
Output is correct |
42 |
Correct |
4 ms |
596 KB |
Output is correct |
43 |
Correct |
4 ms |
632 KB |
Output is correct |
44 |
Correct |
4 ms |
724 KB |
Output is correct |
45 |
Correct |
4 ms |
732 KB |
Output is correct |
46 |
Correct |
4 ms |
640 KB |
Output is correct |
47 |
Correct |
4 ms |
724 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
1 ms |
224 KB |
Output is correct |
52 |
Correct |
2705 ms |
312 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Correct |
2081 ms |
732 KB |
Output is correct |
55 |
Correct |
1203 ms |
724 KB |
Output is correct |
56 |
Execution timed out |
3076 ms |
724 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
2757 ms |
304 KB |
Output is correct |
4 |
Correct |
6 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
212 KB |
Output is correct |
8 |
Correct |
2528 ms |
336 KB |
Output is correct |
9 |
Correct |
2446 ms |
308 KB |
Output is correct |
10 |
Correct |
2584 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
603 ms |
324 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
123 ms |
3744 KB |
Output is correct |
17 |
Correct |
149 ms |
3832 KB |
Output is correct |
18 |
Correct |
128 ms |
3788 KB |
Output is correct |
19 |
Correct |
119 ms |
3808 KB |
Output is correct |
20 |
Correct |
120 ms |
3932 KB |
Output is correct |
21 |
Correct |
124 ms |
3800 KB |
Output is correct |
22 |
Correct |
117 ms |
3832 KB |
Output is correct |
23 |
Correct |
117 ms |
3828 KB |
Output is correct |
24 |
Correct |
120 ms |
3840 KB |
Output is correct |
25 |
Correct |
118 ms |
3828 KB |
Output is correct |
26 |
Correct |
115 ms |
3820 KB |
Output is correct |
27 |
Correct |
121 ms |
3808 KB |
Output is correct |
28 |
Correct |
118 ms |
3832 KB |
Output is correct |
29 |
Correct |
123 ms |
3948 KB |
Output is correct |
30 |
Correct |
143 ms |
3744 KB |
Output is correct |
31 |
Correct |
121 ms |
3828 KB |
Output is correct |
32 |
Correct |
119 ms |
3744 KB |
Output is correct |
33 |
Correct |
128 ms |
3768 KB |
Output is correct |
34 |
Correct |
130 ms |
3912 KB |
Output is correct |
35 |
Correct |
117 ms |
3764 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
3 ms |
340 KB |
Output is correct |
38 |
Correct |
4 ms |
468 KB |
Output is correct |
39 |
Correct |
4 ms |
544 KB |
Output is correct |
40 |
Correct |
4 ms |
528 KB |
Output is correct |
41 |
Correct |
4 ms |
464 KB |
Output is correct |
42 |
Correct |
4 ms |
464 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
1 ms |
328 KB |
Output is correct |
48 |
Correct |
1 ms |
328 KB |
Output is correct |
49 |
Correct |
4 ms |
568 KB |
Output is correct |
50 |
Correct |
6 ms |
476 KB |
Output is correct |
51 |
Correct |
17 ms |
468 KB |
Output is correct |
52 |
Correct |
31 ms |
468 KB |
Output is correct |
53 |
Correct |
38 ms |
596 KB |
Output is correct |
54 |
Correct |
4 ms |
468 KB |
Output is correct |
55 |
Correct |
6 ms |
596 KB |
Output is correct |
56 |
Correct |
4 ms |
568 KB |
Output is correct |
57 |
Correct |
4 ms |
468 KB |
Output is correct |
58 |
Correct |
4 ms |
468 KB |
Output is correct |
59 |
Correct |
4 ms |
552 KB |
Output is correct |
60 |
Correct |
4 ms |
468 KB |
Output is correct |
61 |
Correct |
1 ms |
212 KB |
Output is correct |
62 |
Correct |
94 ms |
5956 KB |
Output is correct |
63 |
Correct |
99 ms |
5936 KB |
Output is correct |
64 |
Correct |
94 ms |
5972 KB |
Output is correct |
65 |
Correct |
91 ms |
5944 KB |
Output is correct |
66 |
Correct |
91 ms |
5860 KB |
Output is correct |
67 |
Correct |
96 ms |
5916 KB |
Output is correct |
68 |
Correct |
1 ms |
212 KB |
Output is correct |
69 |
Correct |
1 ms |
324 KB |
Output is correct |
70 |
Correct |
1 ms |
212 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
1 ms |
212 KB |
Output is correct |
73 |
Correct |
1 ms |
212 KB |
Output is correct |
74 |
Correct |
96 ms |
5956 KB |
Output is correct |
75 |
Correct |
109 ms |
5880 KB |
Output is correct |
76 |
Correct |
140 ms |
5944 KB |
Output is correct |
77 |
Correct |
99 ms |
5964 KB |
Output is correct |
78 |
Correct |
1006 ms |
5972 KB |
Output is correct |
79 |
Correct |
1575 ms |
6004 KB |
Output is correct |
80 |
Execution timed out |
3055 ms |
7244 KB |
Time limit exceeded |
81 |
Halted |
0 ms |
0 KB |
- |