Submission #628138

# Submission time Handle Problem Language Result Execution time Memory
628138 2022-08-13T06:16:39 Z TheQuantiX Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll n, m, x, y, k;

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> k) {
    vector<ll> v(n);
    for (int i = 0; i < m; i++) {
        v[x[i]] += k[i];
    }
    vector<ll> dp1(n + 1);
    vector<ll> dp2(n + 1);
    for (int i = 1; i <= n; i++) {
        if (i != n) {
            dp2[i] = v[i - 1];
            if (i >= 2) {
                dp2[i] = max(dp2[i], dp2[i - 2] + v[i - 1]);
                dp2[i] = max(dp2[i], dp1[i - 2] + v[i - 1]);
            }
            dp2[i] = max(dp2[i], dp1[i - 1] + v[i - 1]);
        }
        if (i != 1) {
            if (i >= 3) {
                dp1[i] = max(dp2[i], dp2[i - 3] + v[i - 1]);
            }
            dp1[i] = max(dp2[i], dp2[i - 2] + v[i - 1]);
            dp1[i] = max(dp2[i], dp1[i - 2] + v[i - 1]);
        }
    }
    return max(*max_element(dp1.begin(), dp1.end()), *max_element(dp2.begin(), dp2.end()));
}

void solve() {
    cin >> n >> m;
    vector<int> x(m);
    vector<int> y(m);
    vector<int> k(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> k[i];
    }
    cout << max_weights(n, m, x, y, k) << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Compilation message

/usr/bin/ld: /tmp/ccauBuLX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnWSk8W.o:fish.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status