제출 #398760

#제출 시각아이디문제언어결과실행 시간메모리
398760VictorCloud Computing (CEOI18_clo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1000000007;

struct str {
    ll val = -1e14;
};

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int n, m;
    vector<pair<ii, pair<ll, int>>> dpvec;
    ll c, f, v, sumc = 0, ans = 0;

    bool samev = 1;

    cin >> n;
    rep(i, 0, n) {
        cin >> c >> f >> v;
        if (v != 1) samev = 0;
        dpvec.push_back({{f, 1}, {v, c}});
    }

    cin >> m;
    rep(i, 0, m) {
        cin >> c >> f >> v;
        sumc += c;
        dpvec.push_back({{f, 0}, {v, c}});
    }

    sort(all(dpvec), greater<>());
    umap<int, str> dp, dp2;
    vector<ll> dp, dp2;
    dp[0].val = 0;

    trav(item, dpvec) {
        int query;
        tie(f, query) = item.first;
        tie(v, c) = item.second;

        trav(val, dp) {
            int cores = val.first;
            ll cost = val.second.val;
            dp2[cores].val = max(dp2[cores].val, cost);
            if (query && cores < sumc)
                dp2[cores + c].val = max(dp2[cores + c].val, cost - v);
            else if (!query && c <= cores)
                dp2[cores - c].val = max(dp2[cores - c].val, cost + v);
        }

        dp.swap(dp2);
        dp2.clear();
    }

    trav(val, dp) ans = max(ans, val.second.val);

    cout << ans << endl;
    return 0;
}

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

clo.cpp: In function 'int main()':
clo.cpp:55:16: error: conflicting declaration 'std::vector<long long int> dp'
   55 |     vector<ll> dp, dp2;
      |                ^~
clo.cpp:54:20: note: previous declaration as 'std::unordered_map<int, str> dp'
   54 |     umap<int, str> dp, dp2;
      |                    ^~
clo.cpp:55:20: error: conflicting declaration 'std::vector<long long int> dp2'
   55 |     vector<ll> dp, dp2;
      |                    ^~~
clo.cpp:54:24: note: previous declaration as 'std::unordered_map<int, str> dp2'
   54 |     umap<int, str> dp, dp2;
      |                        ^~~