답안 #1092657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092657 2024-09-24T17:02:05 Z ortsac Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
10 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define db long double

int INF = 0x3f3f3f3f3f3f3f3f;

struct Val {
    int a, b, idx;
    Val(int x = 0, int y = 0, int z = 0) : a(x), b(y), idx(z) {}
};

bool comp1(const Val& a, const Val& b) {
    return (make_pair(a.b, -a.a) < make_pair(b.b, -b.a));
}

bool comp2(const Val& a, const Val& b) {
    return (make_pair(a.a, a.idx) < make_pair(b.a, b.idx));
}

int32_t main() {
    int n, k;
    cin >> n >> k;
    vector<Val> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].a >> v[i].b;
        if (v[i].b == -1) v[i].b = INF;
        v[i].idx = (i + 1);
    }
    sort(v.begin(), v.end(), comp1);
    cout << fixed << setprecision(14);
    db ans = INF;
    for (int i = 0; i <= k; i++) {
        //cout << i << "\n";
        db mC = 0;
        for (int j = 0; j < i; j++) {
            mC += (((db)v[j].b)/((db)(j + 1)));
            //cout << v[i].idx << " " << mC << " " << v[i].b << "\n";
        }
        //cout << "getting rest\n";
        vector<Val> others;
        for (int j = i; j < n; j++) {
            others.push_back(v[j]);
        }
        sort(others.begin(), others.end(), comp2);
        int rem = (k - i);
        for (int j = 0; j < rem; j++) {
            mC += (((db)others[j].a)/((db)(i + 1)));
            //cout << others[j].idx << " " << mC << "\n";
        }
        ans = min(ans, mC);
    }
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 6 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 6 ms 348 KB Output is correct
19 Correct 10 ms 468 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 6 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 6 ms 348 KB Output is correct
19 Correct 10 ms 468 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Incorrect 0 ms 344 KB Output isn't correct
30 Halted 0 ms 0 KB -