# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
795739 | 1bin | Let's Win the Election (JOI22_ho_t3) | C++14 | 126 ms | 2384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
const int inf = 1e6;
const double eps = 1e-10;
int n, k, a, b;
double dp[505][505];
vector<pair<int, int>> v;
double solve(int x){
double ret = 0;
for(int i = 0; i <= n; i++)
for(int j = 0; j <= n; j++) dp[i][j] = 1e9;
dp[0][0] = 0;
for(int i = 0; i < n; i++){
auto&[b, a] = v[i];
for(int j = 0; j <= min(k - x, i); j++){
dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + 1.0 * a / (x + 1));
if(i - j < x) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1.0 * b / (i - j + 1));
else dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
}
}
return dp[n][k - x];
}
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
for(int i = 0; i < n; i++){
cin >> a >> b;
if(b == -1) b = inf;
v.emplace_back(b, a);
}
sort(all(v));
double ans = inf;
for(int i = 0; i <= k; i++) ans = min(ans, solve(i));
cout << fixed << setprecision(10) << 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... |