Submission #947207

# Submission time Handle Problem Language Result Execution time Memory
947207 2024-03-15T16:02:59 Z lulwpop Cloud Computing (CEOI18_clo) C++14
0 / 100
19 ms 604 KB
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pw(x) (1ll << x)
#define pb push_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define vec vector

using namespace std;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

inline void solve () {
    int n; cin >> n;
    vector <array <ll, 4>> ful;
    vector <ll> c (n), f (n), v (n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> f[i] >> v[i];
        ful.pb({f[i], 1, c[i], v[i]});
    }
    int m; cin >> m;
    vector <ll> qc (m), qf (m), qv (m);
    for (int i = 0; i < m; ++i) {
        cin >> qc[i] >> qf[i] >> qv[i];
        ful.pb({qf[i], 0, qc[i], qv[i]});
    }
    const int MX = 50 * n + 51;
    vector <ll> dp (MX, -1e18); 
    dp[0] = 0;
    sort(all(ful));
    while (sz(ful)) {
        auto [f, type, v, c] = ful.back();
        if (type == 1) {
            for (int i = MX - 1 - c; i >= 0; --i) {
                dp[i + c] = max(dp[i + c], dp[i] - v);
            }
        }
        else {
            for (int i = c; i < MX; ++i) {
                dp[i - c] = max(dp[i - c], dp[i] + v);
            }
        }
        ful.pop_back();
    }
    cout << *max_element(all(dp));
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1; // cin >> t;
    while (t--) solve();
    return 0;
}

Compilation message

clo.cpp: In function 'void solve()':
clo.cpp:40:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |         auto [f, type, v, c] = ful.back();
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 19 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -