Submission #628107

# Submission time Handle Problem Language Result Execution time Memory
628107 2022-08-13T05:18:23 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;

void solve() {
    cin >> n >> m;
    vector<ll> v(n);
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> k;
        v[x] += k;
    }
    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';
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}

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

Compilation message

/usr/bin/ld: /tmp/ccfdD3ET.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccK2QMZT.o:fish.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccfdD3ET.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