Submission #947138

# Submission time Handle Problem Language Result Execution time Memory
947138 2024-03-15T14:48:27 Z baluconisTima Cloud Computing (CEOI18_clo) C++14
0 / 100
20 ms 860 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef tree<ll, null_type,
        less<ll>, rb_tree_tag,
        tree_order_statistics_node_update> oset;

mt19937_64 gen(time(0));
const ll N = 5007, M = 1000007;

int32_t main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif



    ll m;
    cin >> m;
    vector<pair<ll,ll>> all;
    ll c[m], f[m], v[m];
    for(int i = 0; i < m; i++) {
        cin >> c[i] >> f[i] >> v[i];
        all.pb({f[i], i + 1});
    }
    ll n;
    cin >> n;
    ll c2[n], f2[n], v2[n];
    for(int i = 0; i < n; i++) {
       cin >> c2[i] >> f2[i] >> v2[i];
       all.pb({f2[i], -(i + 1)});
    }
    ll cost[m * 50 + 1];
    for(int i = 0; i < m * 50 + 1; i++) {
        cost[i] = -1e18;
    }
    cost[0] = 0;
    ll sum = 0;

    sort(all.rbegin(), all.rend());
    for(auto to: all) {
        if(to.s > 0) {
            ll x = to.s - 1;
            sum += c[x];
            for(int i = sum - c[x]; i >= c[x]; i--) {
                 cost[i] = max(cost[i], cost[i - c[x]] - v[x]);
            }
        } else {
             ll x = (-to.s - 1);
             for(int i = 0; i <= sum - c2[x]; i++) {
                cost[i] = max(cost[i + c2[x]] + v2[x], cost[i]);
             }
        }

        for(int i = sum - 1; i >= 0; i--) {
            cost[i] = max(cost[i], cost[i + 1]);
        }
    }

    cout << cost[0] << '\n';




}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 20 ms 860 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -