Submission #972019

# Submission time Handle Problem Language Result Execution time Memory
972019 2024-04-29T17:53:53 Z 0x34c Cloud Computing (CEOI18_clo) C++17
0 / 100
1 ms 1628 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll

using namespace std;

struct node
{
    int c, f, v;
};

const int MAX_C = 201;
const int INF = 1e9;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, M;
    cin >> N;

    vector<node> pc(N);
    for (int i = 0; i < N; i++)
    {
        int c, f, v;
        cin >> c >> f >> v;

        pc[i] = {c, f, v};
    }

    cin >> M;
    vector<node> qr(M);
    for (int i = 0; i < M; i++)
    {
        int c, f, v;
        cin >> c >> f >> v;

        qr[i] = {c, f, v};
    }

    sort(pc.begin(), pc.end(), [&](node &a, node &b)
         {  if(a.f == b.f) return a.c > b.c; return a.f > b.f; });
    sort(qr.begin(), qr.end(), [&](node &a, node &b)
         { if(a.f == b.f) return a.c > b.c; return a.f > b.f; });

    int dp[M + 1][N + 1][MAX_C];
    for (int i = 0; i <= M; i++)
        for (int j = 0; j <= N; j++)
            for (int c = 0; c < MAX_C; c++)
                dp[i][j][c] = -INF;

    dp[0][0][0] = 0;
    int mx = 0;
    for (int i = 0; i <= M; i++)
        for (int j = 0; j <= N; j++)
        {
            for (int c = MAX_C - 1; c >= 0; c--)
            {
                if (dp[i][j][c] == -INF)
                    continue;

                // skip zakazku
                if (i + 1 <= M)
                {
                    dp[i + 1][j][c] = max(dp[i + 1][j][c], dp[i][j][c]);
                    mx = max(mx, dp[i + 1][j][c]);
                }

                if (j + 1 <= N)
                {
                    // skip pc
                    dp[i][j + 1][c] = max(dp[i][j + 1][c], dp[i][j][c]);
                    mx = max(mx, dp[i][j + 1][c]);
                }

                // take cores
                if (j + 1 <= M && i < N && qr[i].f <= pc[j].f && c + pc[j].c < MAX_C)
                {
                    dp[i][j + 1][c + pc[j].c] = max(dp[i][j + 1][c + pc[j].c], dp[i][j][c] - pc[j].v);
                    mx = max(mx, dp[i][j + 1][c + pc[j].c]);
                }

                // // take next
                // if (qr[i].f <= pc[j].f && qr[i].c <= c + pc[j].c)
                // {
                //     dp[i + 1][j + 1][c + pc[j].c - qr[i].c] = max(dp[i + 1][j + 1][c + pc[j].c - qr[i].c], dp[i][j][c] + (qr[i].v - pc[j].v));
                //     mx = max(mx, dp[i + 1][j + 1][c + pc[j].c - qr[i].c]);
                // }

                // take using c
                if (i < N && qr[i].c <= c)
                {
                    dp[i + 1][j][c - qr[i].c] = max(dp[i + 1][j][c - qr[i].c], dp[i][j][c] + qr[i].v);
                    mx = max(mx, dp[i + 1][j][c - qr[i].c]);
                }
            }
        }

    cout << mx << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 1628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 1628 KB Output isn't correct
4 Halted 0 ms 0 KB -