제출 #972032

#제출 시각아이디문제언어결과실행 시간메모리
9720320x34cCloud Computing (CEOI18_clo)C++17
18 / 100
462 ms2068 KiB
#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 = 1e9;

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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...