# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131335 | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 5 ms | 504 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;
#define ll long long
const int maxn = (int)1e5 + 7;
int n, m;
int a[maxn], b[maxn], c[maxn], d[maxn];
int used[maxn];
main() {
scanf("%d %d", &m, &n);
for (int i = 0; i < m; i++) {
scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
}
if (m > 10) return 0;
ll ans = 1e18;
for (int mask = 0; mask < (1 << m); mask++) {
ll res = 0;
for (int i = 1; i <= n; i++) {
used[i] = -1;
}
for (int i = 0; i < m; i++) {
if ((mask >> i) & 1) {
bool ok = 0;
for (int j = a[i]; j <= b[i]; j++) {
ok |= (used[j] == -1);
used[j] = 0;
}
if (ok)
used[c[i]] = -1;
res += d[i];
}
}
int ok = 0;
for (int j = 1; j <= n; j++) {
ok += (used[j] == -1);
}
if (ok == 1) {
ans = min(ans, res);
}
}
if (ans == (ll)1e18) ans = -1;
printf("%lld", ans);
}
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... |