제출 #124767

#제출 시각아이디문제언어결과실행 시간메모리
124767eriksuenderhaufCloud Computing (CEOI18_clo)C++11
100 / 100
801 ms2168 KiB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ni(n) scanf("%d\n", &(n))
#define prl(n) printf("%lld\n", (n))
using namespace std;
typedef long long ll;
const ll INF = 1e18 + 7;
const int MAXN = 1e5 + 5;
struct order {
    int c, f, v;
    bool operator<(const order &rhs) const {
        if (f == rhs.f)
            return c > rhs.c;
        return f > rhs.f;
    }
} b[4005];
ll dp[2][MAXN];

int main()
{
    int n, m;
    ni(n);
    for (int i = 0; i < n; i++) { // cores, frequency, value
        scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v);
        b[i].v *= -1;
    }
    ni(m);
    for (int i = n; i < n + m; i++) { // cores, frequency, value
        scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v);
        b[i].c *= -1;
    }
    sort(b, b + n + m);
    fill(dp[0], dp[0] + MAXN, -INF);
    dp[0][0] = 0;
    ll ans = 0;
    for (int i = 0; i < n + m; i++) {
        for (int j = 0; j < MAXN; j++) {
            dp[(i&1)^1][j] = dp[i&1][j];
            if (j >= b[i].c && j - b[i].c < MAXN) {
                // max value if you have j cores left after
                // processing first i queries
                dp[(i&1)^1][j] = max(dp[i&1][j], dp[i&1][j - b[i].c] + b[i].v);
            }
        }
    }
    prl(*max_element(dp[((n+m-1)&1)^1], dp[((n+m-1)&1)^1] + MAXN));
    return 0;
}

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

clo.cpp: In function 'int main()':
clo.cpp:35:8: warning: unused variable 'ans' [-Wunused-variable]
     ll ans = 0;
        ^~~
clo.cpp:3:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define ni(n) scanf("%d\n", &(n))
               ~~~~~^~~~~~~~~~~~~~
clo.cpp:22:5: note: in expansion of macro 'ni'
     ni(n);
     ^~
clo.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:3:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define ni(n) scanf("%d\n", &(n))
               ~~~~~^~~~~~~~~~~~~~
clo.cpp:27:5: note: in expansion of macro 'ni'
     ni(m);
     ^~
clo.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &b[i].c, &b[i].f, &b[i].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...