제출 #1058992

#제출 시각아이디문제언어결과실행 시간메모리
1058992manhlinh1501Cloud Computing (CEOI18_clo)C++17
0 / 100
1 ms4980 KiB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 oo64 = 1e15;
const int MAXN = 2e5 + 5;

struct node {
    int x, y, z, type;
    node(int x = 0, int y = 0, int z = 0, int type = 0) : x(x), y(y), z(z), type(type) {}
};

int N, M;
node a[MAXN];
i64 dp[MAXN];
int tot = 0;

signed main() {
#define TASK "code"

    if (fopen(TASK ".inp", "r")) {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    for(int i = 1; i <= N; i++) {
        auto &[x, y, z, type] = a[i];
        cin >> x >> y >> z;
        tot += x;
        type = 0;
    }
    cin >> M;
    for(int i = N + 1; i <= N + M; i++) {
        auto &[x, y, z, type] = a[i];
        cin >> x >> y >> z;
        type = 1;
    }
    sort(a + 1, a + N + M + 1, [&](const node a, const node b) {
        return a.y > b.y;
    });
    for(int i = 1; i <= tot; i++) dp[i] = -oo64;
    dp[0] = 0;
    for(int i = 1; i <= N + M; i++) {
        const auto [x, y, z, type] = a[i];
        if(type == 0) {
            for(int j = tot; j >= x; j--)
                dp[j] = max(dp[j], dp[j - x] - z);
        } else {
            for(int j = 0; j <= tot - x; j++)
                dp[j] = max(dp[j], dp[j + x] + z);
        }
    }
    cout << *max_element(dp + 1, dp + tot + 1);
    return (0 ^ 0);
}

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

clo.cpp: In function 'int main()':
clo.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...