Submission #524999

#TimeUsernameProblemLanguageResultExecution timeMemory
524999codelegendPinball (JOI14_pinball)C++14
11 / 100
1085 ms316 KiB
/** * 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; }

Compilation message (stderr)

pinball.cpp: In function 'void solve(std::istream&, std::ostream&)':
pinball.cpp:23:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |   for (auto &[a, b, c, d] : devices) cin >> a >> b >> c >> d;
      |              ^
pinball.cpp:38:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   38 |           auto [a, b, c, d] = devices[i];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...