Submission #972035

# Submission time Handle Problem Language Result Execution time Memory
972035 2024-04-29T19:04:03 Z 0x34c Cloud Computing (CEOI18_clo) C++17
100 / 100
541 ms 2272 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 INF = 1e15;

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

    int N, M;
    cin >> N;

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

        vals.push_back({c, f, -v});
        MX_C += c;
    }

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

        vals.push_back({-c, f, v});
    }

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

    MX_C++;
    int dp[2][MX_C];
    fill_n(&dp[0][0], 2 * MX_C, -INF);

    dp[0][0] = 0;
    int mx = 0, prev = 0, cur = 1;
    for (int i = 0; i < vals.size(); i++)
    {
        for (int c = MX_C - 1; c >= 0; c--)
        {
            dp[cur][c] = dp[prev][c];
            int cores = c - vals[i].c;
            if (0 <= cores && cores < MX_C)
            {
                dp[cur][c] = max(dp[prev][cores] + vals[i].v, dp[cur][c]);
                mx = max(mx, dp[cur][c]);
            }
        }
        swap(cur, prev);
    }
    cout << mx << endl;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:53:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < vals.size(); i++)
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 29 ms 860 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 135 ms 1116 KB Output is correct
8 Correct 25 ms 600 KB Output is correct
9 Correct 225 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 9 ms 604 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 246 ms 1416 KB Output is correct
6 Correct 455 ms 2088 KB Output is correct
7 Correct 462 ms 1884 KB Output is correct
8 Correct 442 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 30 ms 860 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 464 ms 2016 KB Output is correct
6 Correct 451 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 29 ms 860 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 135 ms 1116 KB Output is correct
16 Correct 25 ms 600 KB Output is correct
17 Correct 225 ms 1900 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 9 ms 604 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 246 ms 1416 KB Output is correct
31 Correct 455 ms 2088 KB Output is correct
32 Correct 462 ms 1884 KB Output is correct
33 Correct 442 ms 2028 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 30 ms 860 KB Output is correct
37 Correct 6 ms 348 KB Output is correct
38 Correct 464 ms 2016 KB Output is correct
39 Correct 451 ms 2028 KB Output is correct
40 Correct 32 ms 856 KB Output is correct
41 Correct 95 ms 1080 KB Output is correct
42 Correct 8 ms 604 KB Output is correct
43 Correct 530 ms 2240 KB Output is correct
44 Correct 501 ms 2244 KB Output is correct
45 Correct 541 ms 2272 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 7 ms 604 KB Output is correct
48 Correct 7 ms 600 KB Output is correct