Submission #1258004

#TimeUsernameProblemLanguageResultExecution timeMemory
1258004chikien2009Let's Win the Election (JOI22_ho_t3)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

void setup()

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int n, m;
double f[501][501][501], res = 1e18;
;
pair<int, int> p[501];

int main()
{
    setup();

    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= m; ++j)
        {
            for (int k = 0; k <= m; ++k)
            {
                f[i][j][k] = 1e18;
            }
        }
    }
    f[0][0][0] = 0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> p[i].second >> p[i].first;
        p[i].first = (p[i].first == -1 ? 1e9 : p[i].first);
    }
    sort(p + 1, p + 1 + n);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j <= m; ++j)
        {
            for (int k = j; k <= m; ++k)
            {
                f[i][j][k] = f[i - 1][j][k];
                if (k > 0)
                {
                    if (k == j)
                    {
                        if (p[i].first != 1e9)
                        {
                            f[i][j][k] = min(f[i][j][k], f[i - 1][j - 1][k - 1] + (double)p[i].first / j);
                        }
                    }
                    else
                    {
                        f[i][j][k] = min(f[i][j][k], f[i - 1][j][k - 1] + (double)p[i].second / (j + 1));
                    }
                }
                if (k == m)
                {
                    res = min(res, f[i][j][k]);
                }
            }
        }
    }
    // for (int i = 0; i <= m; ++i)
    // {
    //     for (int j = 0; j <= m; ++j)
    //     {
    //         cout << fixed << setprecision(2) << f[n][i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    cout << fixed << setprecision(6) << res;
    return 0;
}

Compilation message (stderr)

Main.cpp:7:5: error: expected initializer before 'ios_base'
    7 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
Main.cpp:8:5: error: 'cin' does not name a type
    8 |     cin.tie(0);
      |     ^~~
Main.cpp:9:5: error: 'cout' does not name a type
    9 |     cout.tie(0);
      |     ^~~~
Main.cpp:10:1: error: expected declaration before '}' token
   10 | }
      | ^
Main.cpp: In function 'int main()':
Main.cpp:19:5: error: 'setup' was not declared in this scope; did you mean 'setuid'?
   19 |     setup();
      |     ^~~~~
      |     setuid