Language: C++

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int power(int n, int k) {
    if(k == 0) {
        return 1;
    }
    if(k & 1) {
        return power(n, k - 1) * n;
    } else {
        int t = power(n, k / 2);
        return t * t;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> X(N), Y(N), P(N);
    for(int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> P[i];
    }
    // 前計算
    vector pre1((1 << N), vector(N, INT64_MAX));
    vector pre2((1 << N), vector(N, INT64_MAX));
    {
        for(int bit = 0; bit < (1 << N); bit++) {
            for(int i = 0; i < N; i++) {
                ll tmp1, tmp2;
                tmp1 = tmp2 = min(llabs(X[i]), llabs(Y[i]));
                for(int j = 0; j < N; j++) {
                    if(bit & (1 << j)) {
                        chmin(tmp1, llabs(Y[i] - Y[j]));
                        chmin(tmp2, llabs(X[i] - X[j]));
                    }
                }
                chmin(pre1[bit][i], tmp1);
                chmin(pre2[bit][i], tmp2);
            }
        }
    }
    vector<ll> ans(N + 1, INT64_MAX);
    int limit = power(3, N);
    vector<int> v(N);
    for(int bit = 0; bit < limit; bit++) {
        int tmp = bit;
        for(int i = 0; i < N; i++) {
            v[i] = tmp % 3;
            tmp /= 3;
        }
        // 0:線はひかれていない
        // 1:X軸に平行な線が引かれている
        // 2:Y軸に平行な線が引かれている
        int cnt = 0;
        int bit1 = 0, bit2 = 0;
        for(int i = 0; i < N; i++) {
            if(v[i] == 1) {
                cnt++;
                bit1 |= (1 << i);
            } else if(v[i] == 2) {
                cnt++;
                bit2 |= (1 << i);
            }
        }
        ll res = 0;
        for(int i = 0; i < N; i++) {
            res += P[i] * min(pre1[bit1][i], pre2[bit2][i]);
        }
        chmin(ans[cnt], res);
    }
    for(auto i : ans) {
        cout << i << "\n";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:22: error: no matching function for call to 'chmin(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, ll&)'
   78 |                 chmin(pre1[bit][i], tmp1);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:10:32: note: candidate: 'template<class T> bool chmin(T&, T)'
   10 | template <class T> inline bool chmin(T &a, T b) {
      |                                ^~~~~
a.cc:10:32: note:   template argument deduction/substitution failed:
a.cc:78:22: note:   deduced conflicting types for parameter 'T' ('long int' and 'long long int')
   78 |                 chmin(pre1[bit][i], tmp1);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:79:22: error: no matching function for call to 'chmin(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, ll&)'
   79 |                 chmin(pre2[bit][i], tmp2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:10:32: note: candidate: 'template<class T> bool chmin(T&, T)'
   10 | template <class T> inline bool chmin(T &a, T b) {
      |                                ^~~~~
a.cc:10:32: note:   template argument deduction/substitution failed:
a.cc:79:22: note:   deduced conflicting types for parameter 'T' ('long int' and 'long long int')
   79 |                 chmin(pre2[bit][i], tmp2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~