# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
131335 | Just_Solve_The_Problem | Pinball (JOI14_pinball) | C++11 | 5 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (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... |