이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
pair<double, double> t[509];
double dp[509];
int n, k;
double wynik(int x) {
for(int i = 0; i <= n; i++){
dp[i] = 1000000000000000000;
}
dp[0] = 0;
for(int i = 0; i < n; i++) {
for(int j = min(i + 1, k - x); j >= 0; j--) {
double popdp = dp[j];
if(j > 0) {
dp[j] = dp[j - 1] + t[i].second / (double)(x + 1);
}
else {
dp[j] = 1000000000000000000;
}
if(0 < (i + 1) - j && (i + 1) - j <= x) {
dp[j] = min(dp[j], popdp + t[i].first / (double)((i + 1) - j));
}
else {
dp[j] = min(dp[j], popdp);
}
}
}
return dp[k - x];
}
int main(){
cin>>n>>k;
for(int i = 1; i <= n; i++){
double a, b;
cin>>a>>b;
if(b == -1){
b = 1000000000000000000;
}
t[i - 1] = {b, a};
}
sort(t, t + n);
double w = 1000000000000000000;
for(int i = 0; i <= k; i++){
w = min(w, wynik(i));
}
cout<<fixed<<setprecision(5)<<w<<endl;
}
# | 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... |