Submission #951673

# Submission time Handle Problem Language Result Execution time Memory
951673 2024-03-22T09:47:22 Z Github Cloud Computing (CEOI18_clo) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;

#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define pr printf
#define sc scanf
#define fi first
#define si second


const ll MOD = 998244353;
const ll INF = 1e17;

void setIO(string s){
    freopen((s+".in").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

struct Event{
    ll c, f, v;
};


int main() {
    speedup
    int n; cin >> n;
    vector<Event> a;
    ll mx = 0;
    for (int i = 0; i < n; i++){
        ll ci, f, v;  cin >> ci >> f >> v;
        mx += ci;
        a.push_back({ci, f, -v});
    }
    int m; cin >> m;
    for (int i = 0; i < m; i++){
        ll c, f, v; cin >> c >> f >> ;
        a.push_back({-c, f, v});
    }
    auto cmp = [&](Event x, Event y){
        return (x.f == y.f ? x.v < y.v: x.f > y.f);
    };
    sort(a.begin(), a.end(), cmp);
    vector<ll> oldDP(mx+1, LLONG_MIN);
    oldDP[0] = 0;
    for (Event& x: a){
        vector<ll> newDP(oldDP);
        for (ll c = 0; c <= mx; c++){
            ll p = c - x.c;
            if (0 <= p && p <= mx && oldDP[p] != LLONG_MIN){
                newDP[c] = max(newDP[c], oldDP[p]+x.v);
            }
        }
        oldDP = newDP;
    }
    cout << *max_element(oldDP.begin(), oldDP.end()) << endl;
    return 0;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:46:38: error: expected primary-expression before ';' token
   46 |         ll c, f, v; cin >> c >> f >> ;
      |                                      ^
clo.cpp: In function 'void setIO(std::string)':
clo.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~