| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 658799 | GrandTiger1729 | Let's Win the Election (JOI22_ho_t3) | C++17 | 198 ms | 2396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}컴파일 시 표준 에러 (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... | ||||
