제출 #1336898

#제출 시각아이디문제언어결과실행 시간메모리
1336898ghassanhasanCloud Computing (CEOI18_clo)C++20
72 / 100
586 ms2884 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()

bool cmp(array<int, 3> &a, array<int, 3> &b){
    return a[1] > b[1];
}
void doing() {
    int n; cin >> n;
    vector<array<int, 3>> a;
    for(int i = 0; i < n; i++){
        int c, f, v; cin >> c >> f >> v;
        v = -v;
        a.push_back({c, f, v});
    }
    int m; cin >> m;
    for(int i = 0; i < m; i++){
        int c, f, v; cin >> c >> f >> v;
        c = -c;
        a.push_back({c, f, v});
    }
    sort(all(a), cmp);
    int sz = n + m, mx = n * 50 + 5;
    vector dp(2, vector(mx, -(ll)1e18));
    dp[0][0] = 0;
    for(int i = 0; i < sz; i++){
        dp[1 - (i & 1)] = vector(mx, -(ll)1e18);
        for(int j = 0; j < mx; j++){
            dp[1 - (i & 1)][j] = max(dp[1 - (i & 1)][j], dp[i & 1][j]);
            if(j + a[i][0] >= 0 && j + a[i][0] < mx){
                dp[1 - (i & 1)][j + a[i][0]] = max(dp[1 - (i & 1)][j + a[i][0]], dp[i & 1][j] + a[i][2]);
            }
        }
    }
    cout << *max_element(all(dp[(sz & 1)])) << '\n';
} 

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    {
#ifdef GH
    freopen("IN.txt", "r", stdin);
    cout << string(60, '*') << endl;
#else
    if (const string file = ""; !file.empty()) {
        freopen((file + ".in").c_str(), "r", stdin);
        freopen((file + ".out").c_str(), "w", stdout);
    }
#endif
    }
    int tc = 1;
    // cin >> tc;
    while (tc--)
        doing();
    return 0;
}

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

clo.cpp: In function 'int main()':
clo.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen((file + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen((file + ".out").c_str(), "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...