Submission #529470

# Submission time Handle Problem Language Result Execution time Memory
529470 2022-02-23T04:07:29 Z wiwiho Let's Win the Election (JOI22_ho_t3) C++14
11 / 100
216 ms 460 KB
#include <bits/stdc++.h>

#define iter(a) a.begin(), a.end()
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())

using namespace std;

typedef long long ll;
typedef double ld;

using pii = pair<int, int>;

ll iceil(ll a, ll b){
    return (a + b - 1) / b;
}

int n, k;
vector<int> a, b;

vector<ld> tans;

ld calc(int cnt){
    vector<ld> dp(cnt + 1, 1e87);
    dp[0] = 0;

    for(int i = 1; i <= n; i++){
        for(int c1 = cnt; c1 >= 0; c1--){
            if(dp[c1] != 1e87) dp[c1] += (ld)a[i] / (cnt + 1);
            if(c1 > 0) dp[c1] = min(dp[c1], dp[c1 - 1] + (ld)b[i] / c1);
        }
    }

    //cerr << "calc " << cnt << "  " << dp[cnt][k - cnt] << "\n";
    return dp[cnt];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    a.resize(n + 1);
    b.resize(n + 1);
    tans.resize(k + 1, 1e99);

    vector<pii> tmp(n + 1);
    int c = 0;
    for(int i = 1; i <= n; i++){
        cin >> tmp[i].F >> tmp[i].S;
        if(tmp[i].S != -1) c++;
    }
    sort(tmp.begin() + 1, tmp.end(), [&](pii a, pii b){ return a.S < b.S; });

    for(int i = 1; i <= n; i++) a[i] = tmp[i].F, b[i] = tmp[i].S;

    ld ans = 1e87;
    for(int i = 0; i <= c; i++) ans = min(ans, calc(i));

    cout << fixed << setprecision(20) << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 214 ms 356 KB Output is correct
2 Correct 216 ms 348 KB Output is correct
3 Correct 198 ms 340 KB Output is correct
4 Correct 210 ms 460 KB Output is correct
5 Correct 203 ms 340 KB Output is correct
6 Correct 197 ms 332 KB Output is correct
7 Correct 203 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -