Submission #824413

# Submission time Handle Problem Language Result Execution time Memory
824413 2023-08-14T05:43:05 Z peteza Let's Win the Election (JOI22_ho_t3) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;
bool vis[505][505][505];
long double DP[505][505][505], inf = 1e12, cans = inf;
pair<int, int> dat[505];

long double calc(int i, int j, int k) {
    if(vis[i][j][k]) return DP[i][j][k];
    vis[i][j][k] = 1;
    if(i == 0 || j<k) return DP[i][j][k] = inf;
    DP[i][j][k] = calc(i-1, j, k);
    if(j) DP[i][j][k] = min(DP[i][j][k], calc(i-1, j-1, k) + (((long double)dat[i-1].first)/(k+1)));
    if(j && k && dat[i-1].second != INT_MAX) DP[i][j][k] = min(DP[i][j][k], calc(i-1, j-1, k-1) + (((long double)dat[i-1].second)/k));
    return DP[i][j][k];
}

int main() {
    for(int i=0;i<505;i++)
        for(int j=0;j<505;j++)
            for(int k=0;k<505;k++)
                DP[i][j][k] = inf;
    DP[0][0][0] = 0; vis[0][0][0] = 1;
    cin >> n >> k;
    int bc = n;
    for(int i=0;i<n;i++) {
        cin >> dat[i].first >> dat[i].second;
        if(dat[i].second == -1) bc--, dat[i].second = INT_MAX;
    }
    sort(dat, dat+n, [](pair<int, int> a, pair<int, int> b){
        if(a.second == b.second) return a.first < b.first;
        return a.second < b.second;
    });
    /*for(int i=0;i<=n;i++) {
        for(int j=0;j<=n;j++) {
            for(int k=0;k<=n;k++) {
                cout << calc(i, j, k) << ' ';
            }
            cout << '\n';
        }
        cout << "---\n";
    }*/
    for(int i=0;i<=bc;i++) cans = min(cans, calc(n, k, i));
    cout << cans;
}

Compilation message

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status