# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923819 | OAleksa | Let's Win the Election (JOI22_ho_t3) | C++14 | 4 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 550;
const int inf = 1e18;
int n, k;
pair<int, int> a[N];
double dp1[N][N], dp2[N][N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> k;
vector<int> tm;
for (int i = 1;i <= n;i++) {
cin >> a[i].f >> a[i].s;
tm.push_back(a[i].f);
if (a[i].s == -1)
a[i].s = inf;
}
sort(a + 1, a + n + 1, [&](pair<int, int> x, pair<int, int> y) {
if (x.s == y.s)
return x.f > y.f;
return x.s < y.s;
});
sort(tm.begin(), tm.end());
double ans = 0;
for (int i = 0;i < k;i++)
ans += tm[i];
double t = 0;
for (int i = 2;i <= k + 1;i++) {
t += (double)a[i - 1].s / (i - 1);
vector<int> x;
for (int j = i;j <= n;j++)
x.push_back(a[j].f);
sort(x.begin(), x.end());
double res = t;
for (int j = 0;j < k - i + 1;j++) {
res += (double)x[j] / i;
}
ans = min(ans, res);
}
cout << fixed << setprecision(15) << ans;
}
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... |