답안 #634330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634330 2022-08-24T09:04:54 Z Astrayt Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
19 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++;
            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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 6 ms 212 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 6 ms 212 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Incorrect 0 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -