이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define watch(x) cout << (#x) << " : " << x << '\n'
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 11;
const ll INF = 1e16 + 128;
int l[N], r[N], c[N], d[N];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> l[i] >> r[i] >> c[i] >> d[i];
ll ans = INF;
for (int mask = 0; mask < (1 << n); mask++) {
vector <int> order;
ll sumD = 0ll;
for (int i = 0; i < n; i++)
if ((mask >> i) & 1)
order.push_back(i), sumD += d[i];
int prv = -1;
bool ok = true;
for (int p = 1; p <= m && ok; p++) {
int cur = p;
for (auto& v : order)
if (l[v] <= cur && cur <= r[v])
cur = c[v];
if (prv == -1) prv = cur;
else ok &= (prv == cur);
}
if (ok)
ans = min(ans, sumD);
}
if (ans == INF)
ans = -1;
cout << ans << '\n';
}
main() {
boost;
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
pinball.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
49 | main() {
| ^~~~
# | 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... |