Submission #628110

# Submission time Handle Problem Language Result Execution time Memory
628110 2022-08-13T05:24:57 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(ll n, ll m, vector<ll> x, vector<ll> y, vector<ll> k) {
    vector<ll> v(n);
    for (int i = 0; i < m; i++) {
        v[x[i]] += k[i];
    }
    vector<ll> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[i] = v[i - 1];
        if (i >= 2) {
            dp[i] = max(dp[i], dp[i - 2] + v[i - 1]);
        }
        if (i >= 3) {
            dp[i] = max(dp[i], dp[i - 3] + v[i - 1]);
        }
//        cout << dp[i] << '\n';
    }
    return *max_element(dp.begin(), dp.end());
}

void solve() {
    cin >> n >> m;
    vector<ll> x(m);
    vector<ll> y(m);
    vector<ll> 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/ccXEKXYh.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdTBW5k.o:fish.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccXEKXYh.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status