| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 658799 | GrandTiger1729 | Let's Win the Election (JOI22_ho_t3) | C++17 | 198 ms | 2396 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 <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
const double INF = 1e9;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, K; cin >> n >> K;
pair<double, double> a[n + 1]{};
for (int i = 1; i <= n; i++){
cin >> a[i].first >> a[i].second;
if (a[i].second == -1){
a[i].second = INF;
}
}
sort(a + 1, a + n + 1, [&](pair<double, double> x, pair<double, double> y){
return x.second < y.second;
});
double ans = INF;
for (int t = 0; t < K; t++){
double dp[n + 1][t + 1]{};
for (int i = 0; i <= n; i++){
fill(dp[i], dp[i] + t + 1, INF);
}
dp[0][0] = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= t; j++){
dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + a[i].second / j);
}
for (int j = 0; j <= t; j++){
dp[i][j] = min(dp[i][j], dp[i - 1][j] + a[i].first / (t + 1));
}
}
double cur = 0;
priority_queue<double, vector<double>, greater<double>> pq;
for (int i = n; i > K; i--){
pq.push(a[i].first);
}
double res = INF;
for (int i = K; i >= t; i--){
res = min(res, dp[i][t] + cur);
pq.push(a[i].first);
while (pq.size() > n - K){
cur += pq.top() / (t + 1);
pq.pop();
}
}
ans = min(ans, res);
}
cout << fixed << setprecision(15) << ans;
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... | ||||
