제출 #1340859

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

using namespace std;

#define MAXN 2001
#define MAXC 100001
// #define MAXC 100

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

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

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

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

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

    int len = N + M;

    for (int i = N + 1; i <= len; ++i) {
        int c, f, v;
        scanf ("%d%d%d", &c, &f, &v);
        inp[i][1] = -c;
        inp[i][0] = -f;
        inp[i][2] = 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 [_, c, v] = inp[i];

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

        memcpy (dp0, dp, sizeof dp0);
    }

    long long ans = 0;

    for (int i = 0; i < MAXC; ++i)
        if (dp[i] > ans)
            ans = dp[i];

    printf ("%lld\n", ans);

    return 0;
}

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

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