Submission #958974

#TimeUsernameProblemLanguageResultExecution timeMemory
958974typ_ikPinball (JOI14_pinball)C++17
11 / 100
296 ms456 KiB
#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;
}

Compilation message (stderr)

pinball.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...