# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526352 | model_code | Let's Win the Election (JOI22_ho_t3) | C++17 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N, K, A[509], B[509];
vector<int> vec1, vec2;
int main() {
// 入力
cin >> N >> K;
for (int i = 0; i < N; i++) {
cin >> A[i] >> B[i];
if (B[i] == -1) vec1.push_back(A[i]);
if (B[i] == A[i]) vec2.push_back(A[i]);
}
// ソート
sort(vec1.begin(), vec1.end());
sort(vec2.begin(), vec2.end());
// ç”ãˆã‚’求ã‚ã‚‹
double Answer = 1e9;
for (int Goal = 0; Goal <= K; Goal++) {
if (K - Goal > vec1.size() || Goal > vec2.size()) continue;
double sum = 0;
for (int i = 0; i < K - Goal; i++) sum += 1.0 * vec1[i] / (Goal+1);
for (int i = 0; i < Goal; i++) sum += 1.0 * vec2[i] / (i+1);
Answer = min(Answer, sum);
}
printf("%.12lf\n", Answer);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |