Submission #834713

# Submission time Handle Problem Language Result Execution time Memory
834713 2023-08-22T17:34:29 Z GordonRemzi007 Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#define ll long long

using namespace std;

ll max_weights(ll n, ll m, vector<ll> x, vector<ll> y, vector<ll> w) {
    ll res;
    if(n == 2) {
        ll r0 = 0, r1 = 0;
        for(ll i = 0; i < m; i++) {
            if(x[i]) r1+=w[i];
            else r0+=w[i];
        }
        res = max(r0, r1);
    } else {
        vector<ll> pref0(n), pref1(n);
        for(int i = 0; i < m; i++) {
            if(x[i]) pref1[y[i]] = w[i];
            else pref0[y[i]] = w[i];
        }
        for(int i = 1; i < n; i++) {
            pref0[i]+=pref0[i-1];
            pref1[i]+=pref1[i-1];
        }
        res = pref1[n-1];
        for(int i = 0; i < n; i++) res = max(res, pref0[i]+pref1[n-1]-pref1[i]);
    }
    return res;
}

Compilation message

/usr/bin/ld: /tmp/cciqGSQs.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