# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
524999 | codelegend | Pinball (JOI14_pinball) | C++14 | 1085 ms | 316 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author codelegend
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)
#define SZ(v) ((int)size(v))
void prec() {}
void solve(istream &cin, ostream &cout) {
int m, n;
cin >> m >> n;
vector<array<int, 4>> devices(m);
for (auto &[a, b, c, d] : devices) cin >> a >> b >> c >> d;
const ll inf = numeric_limits<ll>::max();
ll best = inf;
for (int mask = 0; mask < (1 << m); mask++) {
ll cost = 0;
for (int i = 0; i < m; i++) {
if (mask & (1 << i)) cost += devices[i][3];
}
int fin = -1;
bool ok = true;
for (int s = 1; s <= n; s++) {
int x = s;
for (int i = 0; i < m; i++) {
if (mask & (1 << i)) {
auto [a, b, c, d] = devices[i];
if (a <= x && x <= b) x = c;
}
}
if (fin == -1) fin = x;
if (fin != x) {
ok = false;
break;
}
}
if (ok) best = min(best, cost);
}
if (best == inf) best = -1;
cout << best << '\n';
}
//====== Submission Template; Ignore ========//
struct Pinball {
void solve(std::istream &in, std::ostream &out) { ::solve(in, out); }
};
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
prec();
Pinball solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
solver.solve(in, out);
return 0;
}
컴파일 시 표준 에러 (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... |