Submission #958974

# Submission time Handle Problem Language Result Execution time Memory
958974 2024-04-07T10:36:56 Z typ_ik Pinball (JOI14_pinball) C++17
11 / 100
296 ms 456 KB
#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

pinball.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 452 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 452 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
9 Runtime error 296 ms 440 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 452 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
9 Runtime error 296 ms 440 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 452 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 5 ms 348 KB Output is correct
9 Runtime error 296 ms 440 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -