제출 #936310

#제출 시각아이디문제언어결과실행 시간메모리
936310qwe1rt1yuiop1Let's Win the Election (JOI22_ho_t3)C++14
56 / 100
2555 ms112520 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
using pii = pair<int, int>;

void solve()
{
    int n, kk;
    cin >> n >> kk;
    vector<pii> v(n);
    for (auto &[b, a] : v)
    {
        cin >> a >> b;
        if (b == -1)
            b = INT_MAX;
    }
    cout << fixed << setprecision(5);
    sort(v.begin(), v.end());
    // for (auto &[b, a] : v)
    //     if (b == INT_MAX)
    //         b = -1;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
        a[i] = v[i].second, b[i] = v[i].first;

    double ans = 1e15;
    for (int goal = 1; goal <= kk + 1; ++goal)
    {
        vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(kk + 1, vector<double>(goal + 1, 1e15)));
        dp[0][0][1] = 0;
        for (int i = 0; i < n; ++i)
        {
            dp[i + 1] = dp[i];
            for (int j = 0; j < kk; ++j)
            {
                for (int k = 1; k <= goal; ++k)
                {
                    dp[i + 1][j + 1][k] = min(dp[i + 1][j + 1][k], dp[i][j][k] + 1.0 * a[i] / goal);
                    if (k != goal)
                        dp[i + 1][j + 1][k + 1] = min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1.0 * b[i] / k);
                }
            }
        }
        ans = min(ans, dp[n][kk][goal]);
    }
    cout << ans << '\n';
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:11:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   11 |     for (auto &[b, a] : v)
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...