제출 #795739

#제출 시각아이디문제언어결과실행 시간메모리
7957391binLet's Win the Election (JOI22_ho_t3)C++14
100 / 100
126 ms2384 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
const int inf = 1e6;
const double eps = 1e-10;
int n, k, a, b;
double dp[505][505];
vector<pair<int, int>> v;

double solve(int x){
    double ret = 0;
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++) dp[i][j] = 1e9;
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        auto&[b, a] = v[i];
        for(int j = 0; j <= min(k - x, i); j++){
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + 1.0 * a / (x + 1));
            if(i - j < x) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1.0 * b / (i - j + 1));
            else dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    return dp[n][k - x];
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(b == -1) b = inf;
        v.emplace_back(b, a);
    }
    sort(all(v));
    double ans = inf;
    for(int i = 0; i <= k; i++) ans = min(ans, solve(i));
    cout << fixed << setprecision(10) << ans;
    return 0;
}

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

Main.cpp: In function 'double solve(int)':
Main.cpp:20:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |         auto&[b, a] = v[i];
      |              ^
Main.cpp:15:12: warning: unused variable 'ret' [-Wunused-variable]
   15 |     double ret = 0;
      |            ^~~
#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...