답안 #824347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824347 2023-08-14T03:45:37 Z peteza Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
1 ms 468 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;
int a[1005], b[1005];
vector<int> sA, sB;
bool vis[1005];

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    cin >> n >> k;
    for(int i=0;i<n;i++) {
        cin >> a[i] >> b[i];
        sA.emplace_back(i); 
        if(b[i] != -1) sB.emplace_back(i);
    }
    sort(sA.begin(), sA.end(), [&](int i, int j){
        return a[i] <= a[j];
    });
    sort(sB.begin(), sB.end(), [&](int i, int j){
        return b[i] <= b[j];
    });
    long double ans, cans = 1e18;
    for(int bs=0;bs<=min((int)sB.size(), k);bs++) {
        memset(vis, 0, sizeof vis);
        int cnt = 0;
        ans = 0;
        for(int i=0;i<bs;i++) {
            cnt++;
            vis[sB[i]] = 1;
            ans += 1.00*b[sB[i]]/(i+1);
        }
        for(int i=0;i<n&&cnt!=k;i++) {
            if(vis[sA[i]]) continue;
            cnt++;
            ans += 1.00*a[sA[i]]/(bs+1);
        }
        if(cnt != k) continue;
        cans = min(cans, ans);
    }
    cout << fixed << setprecision(10) << cans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 11
11 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 256 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 256 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 256 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 1 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 1 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -