답안 #955704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955704 2024-03-31T10:49:16 Z vjudge1 Pinball (JOI14_pinball) C++17
29 / 100
1000 ms 15520 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll m, n, i, j, k, a, b, w = 0, r = (1LL << 50);
    cin >> m >> n;
    vector<vector<ll> > v, vv(m), dp, ndp;
    vector<ll> d(m), s(3 * m);
    for (i = 0; i < m; i++)
    {
        cin >> j;
        v.push_back({j - 1, i, -1});
        cin >> j;
        v.push_back({j - 1, i, 1});
        cin >> j;
        v.push_back({j - 1, i, 0});
        cin >> d[i];
    }
    sort(v.begin(), v.end());
    if (v[0][0] || v[3 * m - 1][0] != n - 1)
    {
        cout << -1;
        return 0;
    }
    for (i = 0; i < 3 * m; i++)
    {
        if (!i)
            s[i] = 0;
        else if (v[i][0] > v[i - 1][0])
            s[i] = s[i - 1] + 1;
        else
            s[i] = s[i - 1];
        w = max(w, s[i]);
    }
    for (i = 0; i < 3 * m; i++)
        v[i] = {v[i][1], s[i], v[i][2]};
    sort(v.begin(), v.end());
    for (i = 0; i < m; i++)
        vv[i] = {v[3 * i][1], v[3 * i + 1][1], v[3 * i + 2][1]};
    ndp.resize(w + 1);
    for (i = 0; i <= w; i++)
    {
        ndp[i].resize(i + 1);
        for (j = 0; j <= i; j++)
        {
            if (j == i)
                ndp[i][j] = 0;
            else
                ndp[i][j] = r;
        }
    }
    dp = ndp;
    for (i = m - 1; i >= 0; i--)
    {
        for (j = 0; j <= w; j++)
        {
            for (k = 0; k <= j; k++)
            {
                if (dp[j][k] < r && k <= vv[i][1] && vv[i][1] <= j)
                {
                    a = min(k, vv[i][0]);
                    b = max(j, vv[i][2]);
                    ndp[b][a] = min(ndp[b][a], dp[j][k] + d[i]);
                }
            }
        }
        dp = ndp;
    }
    if (dp[w][0] < r)
        cout << dp[w][0];
    else
        cout << -1;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 440 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 11 ms 1072 KB Output is correct
12 Correct 51 ms 3164 KB Output is correct
13 Correct 53 ms 3336 KB Output is correct
14 Correct 42 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 440 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 11 ms 1072 KB Output is correct
12 Correct 51 ms 3164 KB Output is correct
13 Correct 53 ms 3336 KB Output is correct
14 Correct 42 ms 3164 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Execution timed out 1047 ms 15520 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 440 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 11 ms 1072 KB Output is correct
12 Correct 51 ms 3164 KB Output is correct
13 Correct 53 ms 3336 KB Output is correct
14 Correct 42 ms 3164 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Execution timed out 1047 ms 15520 KB Time limit exceeded
18 Halted 0 ms 0 KB -