# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117083 | arman_ferdous | Pinball (JOI14_pinball) | C++14 | 2 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5+100;
int n, m, a[N], b[N], c[N], Del[N];
ll d[N];
vector< pair<ll,int> > v;
int dfs(int u, int lev) {
if(lev == n + 2) return u;
if(Del[lev]) return dfs(u, lev + 1);
if(a[lev] <= u && u <= b[lev]) return dfs(c[lev], lev + 1);
return dfs(u, lev + 1);
}
bool ok() {
return dfs(1, 1) == dfs(m, 1);
}
int main() {
scanf("%d %d", &n, &m);
for(int i = 2; i < n + 2; i++) {
scanf("%d %d %d %lld", &a[i], &b[i], &c[i], &d[i]);
v.push_back({-d[i], i});
} sort(v.begin(), v.end());
ll ans = 0;
for(int i = 0; i < n; i++) {
Del[v[i].second] = 1;
if(!ok()) ans -= v[i].first, Del[v[i].second] = 0;
} printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |