이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
pair<pair<int, int>, pair<int, int>> arr[20];
bool xd[100];
int main() {
int n, m, a, b, c, d;
cin >> n >> m;
for(int i=0; i<m; i++) {
cin >> a >> b >> c >> d;
arr[i] = {{a, b}, {c, d}};
}
long long cost;
long long res = 1000000000000000;
int dd;
for(int i=1; i<(1<<m); i++) {
for(int j=0; j<=n; j++) {
xd[j] = false;
}
cost = 0;
for(int j=0; j<m; j++) {
if(i & (1<<j)) {
cost+=arr[j].second.second;
for(int k = arr[j].first.first; k<=arr[j].first.second; k++) {
xd[k] = true;
}
xd[arr[j].second.first] = false;
}
}
dd = 0;
for(int j=1; j<=n; j++) {
if(xd[j] == false) {
dd++;
}
}
if(dd == 1) {
res = min(res, cost);
}
}
if(res != 1000000000000000) {
cout << res;
}
else {
cout << -1;
}
}
# | 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... |