| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 886982 | dubabuba | Let's Win the Election (JOI22_ho_t3) | C++14 | 2567 ms | 760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
const int mxn = 20;
int a[mxn], n;
int b[mxn], k;
vector<int> good;
vector<int> badd;
double ans = 1e9;
void solve(int map) {
vector<int> vote = badd;
vector<int> help;
double ret = 0.0;
for(int i = 0; i < good.size(); i++)
if(map & (1 << i))
help.push_back(good[i]);
else
vote.push_back(good[i]);
if(help.size() > k) return;
sort(help.begin(), help.end(), [&](int i, int j) { return b[i] < b[j]; });
sort(vote.begin(), vote.end(), [&](int i, int j) { return a[i] < a[j]; });
int helpers = 0;
for(int i : help) {
ret += 1.0 * b[i] / (1.0 + helpers);
helpers++;
}
for(int j = 0; j < (k - help.size()); j++) {
int i = vote[j];
ret += 1.0 * a[i] / (1.0 + helpers);
}
ans = min(ans, ret);
}
int main() {
cin >> n >> k;
for(int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
if(b[i] == -1) {
b[i] = inf;
badd.push_back(i);
}
else
good.push_back(i);
}
for(int bit = 0; bit < (1 << good.size()); bit++)
solve(bit);
cout << setprecision(5) << fixed << ans << '\n';
return 0;
}
컴파일 시 표준 에러 (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... | ||||
