제출 #1340864

#제출 시각아이디문제언어결과실행 시간메모리
1340864msunCloud Computing (CEOI18_clo)C++20
100 / 100
486 ms2056 KiB
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>

#define int long long

using namespace std;

#define MAXN 2020
#define MAXC 100100
// #define MAXC 100

array<int, 3> inp[2 * MAXN];
int           dp[MAXC], dp0[MAXC];

signed
main ()
{
    // freopen ("test.in", "r", stdin);

    int N;
    scanf ("%lld", &N);

    int C = 0;

    for (int i = 1; i <= N; ++i) {
        int c, f, v;
        scanf ("%lld%lld%lld", &c, &f, &v);
        inp[i][2] = c;
        inp[i][0] = -f;
        inp[i][1] = -v;
        C += c;
    }

    int M;
    scanf ("%lld", &M);

    int len = N + M;

    for (int i = N + 1; i <= len; ++i) {
        int c, f, v;
        scanf ("%lld%lld%lld", &c, &f, &v);
        inp[i][2] = -c;
        inp[i][0] = -f;
        inp[i][1] = v;
    }

    sort (inp + 1, inp + len + 1);

    memset (dp, -0x3f, sizeof dp);
    memset (dp0, -0x3f, sizeof dp);
    dp[0] = dp0[0] = 0;

    for (int i = 1; i <= len; ++i) {
        auto [_, v, c] = inp[i];

        for (int j = 0; j <= C; ++j)
            if (j >= c && j - c <= C)
                dp[j] = max (dp0[j], dp0[j - c] + v);

        memcpy (dp0, dp, sizeof dp0);
    }

    printf ("%lld\n", *max_element (dp, dp + C + 1));

    return 0;
}

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

clo.cpp: In function 'int main()':
clo.cpp:23:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf ("%lld", &N);
      |     ~~~~~~^~~~~~~~~~~~
clo.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf ("%lld%lld%lld", &c, &f, &v);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:37:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf ("%lld", &M);
      |     ~~~~~~^~~~~~~~~~~~
clo.cpp:43:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         scanf ("%lld%lld%lld", &c, &f, &v);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...