# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
908858 |
2024-01-17T00:47:22 Z |
vjudge1 |
Pinball (JOI14_pinball) |
C++17 |
|
1000 ms |
444 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define range(i, a, b) for (ll i = a; i < b; i++)
#define all(x) begin(x), end(x)
#define INF (1ll << 60)
struct TPos {
ll l, r, c, w;
};
ll m, n;
vector<TPos> arr;
ll check(ll i, ll l, ll r, ll cnt) {
if (l == 1 && r == n) return cnt;
if (!i) return INF;
ll ans = INF;
if (l <= arr[i - 1].c && arr[i - 1].c <= r && (arr[i - 1].l < l || r < arr[i - 1].r)) {
ans = check(i - 1, min(l, arr[i - 1].l), max(r, arr[i - 1].r), cnt + arr[i - 1].w);
}
ans = min(ans, check(i - 1, l, r, cnt));
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> m >> n;
arr.resize(m);
ll ans = INF;
range(i, 0, m) {
cin >> arr[i].l >> arr[i].r >> arr[i].c >> arr[i].w;
ans = min(check(i, arr[i].l, arr[i].r, arr[i].w), ans);
}
cout << (ans == INF ? -1 : ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1056 ms |
444 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1056 ms |
444 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1056 ms |
444 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |