Submission #634329

# Submission time Handle Problem Language Result Execution time Memory
634329 2022-08-24T09:04:01 Z Astrayt Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
22 ms 340 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define N 100005

struct city{
    int i, a, b;
};

void solve(){
    int n, k, cnt = 0, j = 0; cin >> n >> k;
    double ans = 1e18;
    vector<int> used(n, 0);
    vector<city> v(n);
    for(auto &[i, a, b]:v){
        cin >> a >> b;
        if(b != -1) ++cnt;
        b = (b == -1 ? 1e18 : b);
        i = j++;
    }
    for(j = 0; j <= min(k, cnt); ++j){
        int c = 1, cc = j;
        double t = 0;
        used.assign(n, 0);
        sort(v.begin(), v.end(), [](city a, city b){return a.b < b.b;});
        for(int i = 0; i < j; ++i){
            t += (double)v[i].b / (double) c;
            c++; cc++;
            used[v[i].i] = 1;
        }
        sort(v.begin(), v.end(), [](city a, city b){return a.a < b.a;});
        for(int i = 0; cc <= k && i < n; ++i){
            if(used[v[i].i]) continue;
            t += (double)v[i].a / (double) c;
            cc++;
        }
        ans = min(ans, t);
    }
    cout << fixed << setprecision(14) << ans << '\n';
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -