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;
#ifdef MIKU
const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
const int MXN = 505;
int n, k;
pii p[MXN];
double calc(int x) {
sort(p, p + n, [](pii a, pii b) -> bool {
if (a.sc == -1 && b.sc == -1) return a.fs < b.fs;
if (a.sc == -1) return false;
if (b.sc == -1) return true;
return a.sc < b.sc;
});
sort(p + x, p + n, [](pii a, pii b) -> bool {
return a.fs < b.fs;
});
double ans = 0.0;
FOR(i, 0, n) cout << p[i].fs << ' ' << p[i].sc << '\n';
FOR(i, 0, x) ans += (double) p[i].sc / (i + 1);
FOR(i, x, k) ans += (double) p[i].fs / (x + 1);
return ans;
}
void miku() {
cin >> n >> k;
FOR(i, 0, n) cin >> p[i].fs >> p[i].sc;
int x = count_if(p, p + n, [](pii a) -> bool {
return a.sc != -1;
});
double ans = 3.9e18;
FOR(i, 0, min(x, k) + 1) {
double x = calc(i);
debug(x);
ans = min(ans, x);
}
cout << fixed << setprecision(10) << ans << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'void miku()':
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
11 | #define debug(...) 39
| ^~
Main.cpp:51:9: note: in expansion of macro 'debug'
51 | debug(x);
| ^~~~~
# | 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... |