Submission #40355

# Submission time Handle Problem Language Result Execution time Memory
40355 2018-01-31T10:55:44 Z krauch Pinball (JOI14_pinball) C++14
18 / 100
1000 ms 3372 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > PII;

#define F first
#define S second
#define mkp make_pair
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)

const ll ool = 1e18 + 9;
const int N = 3e5 + 3, oo = 1e9 + 9;

int n, m, a[N], b[N], c[N], cost[N];
ll d[N], ans = ool;

int main() {
    #ifdef krauch
        freopen("input.txt", "r", stdin);
    #endif

    scanf("%d%d", &m, &n);
    forn(i, 1, m) {
        scanf("%d%d%d%d", a + i, b + i, c + i, cost + i);
        cost[2 * m - i + 1] = cost[i];
        a[2 * m - i + 1] = a[i];
        b[2 * m - i + 1] = b[i];
        c[2 * m - i + 1] = c[i];
    }

    forn(i, 1, m) {
        d[i] = ool;
        if (a[i] == 1) d[i] = cost[i];
        forn(j, 1, i - 1) {
            if (a[i] <= c[j] && c[j] <= b[i]) d[i] = min(d[i], d[j] + cost[i]);
        }
        d[2 * m - i + 1] = d[i];
    }
    forn(i, m + 1, 2 * m) {
        forn(j, m + 1, i - 1) {
            if (a[j] <= c[i] && c[i] <= b[j]) d[i] = min(d[i], d[j] + cost[i]);
        }
        if (b[i] == n) ans = min(ans, d[i]);
    }

    cout << ans << "\n";

    return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:28:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &m, &n);
                          ^
pinball.cpp:30:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", a + i, b + i, c + i, cost + i);
                                                         ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Incorrect 2 ms 724 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 2 ms 752 KB Output is correct
3 Correct 2 ms 776 KB Output is correct
4 Correct 2 ms 800 KB Output is correct
5 Correct 2 ms 824 KB Output is correct
6 Correct 2 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 840 KB Output is correct
2 Incorrect 2 ms 896 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 587 ms 1876 KB Output is correct
2 Execution timed out 1068 ms 3372 KB Time limit exceeded
3 Halted 0 ms 0 KB -